Friday, August 25, 2017

Add a new virtual hard disk to your Linux VM

1. log in as root
2. run this command and make note of the sdx entries
[root@localhost ~]# ls -l /dev/sd*
brw-r----- 1 root disk 8,  0 Aug 25 03:46 /dev/sda
brw-r----- 1 root disk 8,  1 Aug 25 10:46 /dev/sda1
brw-r----- 1 root disk 8,  2 Aug 25 03:46 /dev/sda2
brw-r----- 1 root disk 8,  3 Aug 25 03:46 /dev/sda3
brw-r----- 1 root disk 8,  4 Aug 25 10:46 /dev/sda4

3.  Add a new virtual hard disk to your VM from VMware Workstation GUI

4. run this command and you'll see the new entry for your newly added disk
[root@localhost ~]# ls -l /dev/sd*
brw-r----- 1 root disk 8,  0 Aug 25 03:46 /dev/sda
brw-r----- 1 root disk 8,  1 Aug 25 10:46 /dev/sda1
brw-r----- 1 root disk 8,  2 Aug 25 03:46 /dev/sda2
brw-r----- 1 root disk 8,  3 Aug 25 03:46 /dev/sda3
brw-r----- 1 root disk 8,  4 Aug 25 10:46 /dev/sda4
brw-r----- 1 root disk 8, 16 Aug 25 03:46 /dev/sdb

5. check your current file system type, it is ext3 for /
[root@localhost ~]# mount |grep ^/dev
/dev/sda4 on / type ext3 (rw)
/dev/sda2 on /tmp type ext2 (rw)
/dev/sda1 on /boot type ext3 (rw)

6. Check disk size and partition table with fdisk
[root@localhost ~]# fdisk -l

Disk /dev/sda: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          65      522081   83  Linux
/dev/sda2              66         326     2096482+  83  Linux
/dev/sda3             327         587     2096482+  82  Linux swap / Solaris
/dev/sda4             588        2610    16249747+  83  Linux

Disk /dev/sdb: 26.8 GB, 26843545600 bytes
255 heads, 63 sectors/track, 3263 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdb doesn't contain a valid partition table

7. create an ext3 file system on the whole new disk
$ mkfs -t ext3 /dev/sdb


8. make directory as mount point
$ mkdir /bld

9. edit fstab for a permanent mount
/dev/sdb                 /bld                   ext3    defaults        0 0

10. reboot your VM



No comments: