L. J. Jaeckel                      ◄ Home        ◄ Back to Debian log
CMPSC 210 – Linux System Administration
February 18-19, 2011

Transcript showing creation of a second virtual hard disk drive

Note: This transcript is edited to make it more readable, and to make it an HTML page:

Nevertheless, I, Jay Jaeckel, hereby certify that this transcript, as shown here, substantially and correctly shows what actually happened.

First things first: Creating the virtual disk in VMware.

Here are the detailed steps running the Add Hardware Wizard:

Now, boot up the Virtual Machine

Log in.
Start a terminal window.
This entire procedure is done at the root (super-user).
First, before creating anything new, we examine what we have so far:

jay@drizzle:/home/jay $ su -
Password:         

root@drizzle:/root # date
Sat Feb 19 01:08:28 PST 2011

root@drizzle:/root # df
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/sda1              9835552   3856272   5479664  42% /
tmpfs                   365644         0    365644   0% /lib/init/rw
udev                     10240       660      9580   7% /dev
tmpfs                   365644         0    365644   0% /dev/shm

root@drizzle:/root # cat /etc/fstab
# /etc/fstab: static file system information.
#
#                
proc            /proc           proc    defaults        0       0
/dev/sda1       /               ext3    errors=remount-ro 0       1
/dev/sda5       none            swap    sw              0       0
/dev/hdc        /media/cdrom0   udf,iso9660 user,noauto     0       0
/dev/fd0        /media/floppy0  auto    rw,user,noauto  0       0

root@drizzle:/root # mount
/dev/sda1 on / type ext3 (rw,errors=remount-ro)
tmpfs on /lib/init/rw type tmpfs (rw,nosuid,mode=0755)
proc on /proc type proc (rw,noexec,nosuid,nodev)
sysfs on /sys type sysfs (rw,noexec,nosuid,nodev)
procbususb on /proc/bus/usb type usbfs (rw)
udev on /dev type tmpfs (rw,mode=0755)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)
devpts on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=620)
none on /proc/fs/vmblock/mountPoint type vmblock (rw)

fdisk shows that the new disk /dev/sdb is visible, and it’s geometry is known, but there are no partitions yet:

root@drizzle:/root # fdisk -l

Disk /dev/sda: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x0006e7e2

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1        1244     9992398+  83  Linux
/dev/sda2            1245        1305      489982+   5  Extended
/dev/sda5            1245        1305      489951   82  Linux swap / Solaris

Disk /dev/sdb: 2147 MB, 2147483648 bytes
255 heads, 63 sectors/track, 261 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x00000000

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

I am doing the entire partitioning with fdisk rather that cfdisk so I can have the following transcript of the entire session. That’s not so easy to do with cfdisk.

root@drizzle:/root # fdisk /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x3fe1592b.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

Command (m for help): m
Command action
   a   toggle a bootable flag
   b   edit bsd disklabel
   c   toggle the dos compatibility flag
   d   delete a partition
   l   list known partition types
   m   print this menu
   n   add a new partition
   o   create a new empty DOS partition table
   p   print the partition table
   q   quit without saving changes
   s   create a new empty Sun disklabel
   t   change a partition's system id
   u   change display/entry units
   v   verify the partition table
   w   write table to disk and exit
   x   extra functionality (experts only)

Begin the process of creating a new partition here:

Note that, unlike cfdisk, we can create BOTH partitions and tweak them as desired, BEFORE writing the partition table out. In cfdisk it seems you have to create one partition, then write it, then create the next partition and write it.

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-261, default 1): 1
Last cylinder or +size or +sizeM or +sizeK (1-261, default 261): 130

I chose last cylinder of 130 because that appears to be about half the total disk size of 261 cylinders.

Display the partition table so far, and change the sdb1 partition type from 83 (Linux) to 82 (swap):

Command (m for help): p

Disk /dev/sdb: 2147 MB, 2147483648 bytes
255 heads, 63 sectors/track, 261 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x3fe1592b

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1         130     1044193+  83  Linux

Command (m for help): t
Selected partition 1
Hex code (type L to list codes): 82
Changed system type of partition 1 to 82 (Linux swap / Solaris)

Command (m for help): p

Disk /dev/sdb: 2147 MB, 2147483648 bytes
255 heads, 63 sectors/track, 261 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x3fe1592b

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1         130     1044193+  82  Linux swap / Solaris

Now repeat all the above steps, more or less, to create the second partition on this disk:

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (131-261, default 131): 131
Last cylinder or +size or +sizeM or +sizeK (131-261, default 261): 261

Command (m for help): p

Disk /dev/sdb: 2147 MB, 2147483648 bytes
255 heads, 63 sectors/track, 261 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x3fe1592b

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1         130     1044193+  82  Linux swap / Solaris
/dev/sdb2             131         261     1052257+  83  Linux

Write the partition table and exit:

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

root@drizzle:/root # 

========================================================================

The cfdisk program has options to display the partition table in a variety of different formats, including by sectors and even a raw hex dump. Here is what some of these listings look like:

root@drizzle:/root # cfdisk /dev/sdb

                             cfdisk (util-linux-ng 2.13.1.1)

                                   Disk Drive: /dev/sdb
                             Size: 2147483648 bytes, 2147 MB
                   Heads: 255   Sectors per Track: 63   Cylinders: 261

    Name          Flags       Part Type   FS Type            [Label]          Size (MB)
 ----------------------------------------------------------------------------------------
    sdb1                       Primary    Linux swap / Solaris                  1069.29
    sdb2                       Primary    Linux                                 1077.52

Partition table in “Table” format:

Partition Table for /dev/sdb

         ---Starting---      ----Ending----    Start     Number of
 # Flags Head Sect Cyl   ID  Head Sect Cyl     Sector    Sectors
-- ----- ---- ---- ---- ---- ---- ---- ---- ----------- -----------
 1  0x00    1    1    0 0x82  254   63  129          63     2088387
 2  0x00    0    1  130 0x83  254   63  260     2088450     2104515
 3  0x00    0    0    0 0x00    0    0    0           0           0
 4  0x00    0    0    0 0x00    0    0    0           0           0

Partition table in “Sector” format:

Partition Table for /dev/sdb

               First       Last
 # Type       Sector      Sector   Offset    Length   Filesystem Type (ID) Flag
-- ------- ----------- ----------- ------ ----------- -------------------- ----
 1 Primary           0     2088449     63     2088450 Linux swap / So (82) None
 2 Primary     2088450     4192964      0     2104515 Linux (83)           None

Partition table in “Raw” (Hex dump) format. (Note the partition data is near the end of this.)

Disk Drive: /dev/sdb
Sector 0:
0x000: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x010: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x020: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x030: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x040: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x050: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x060: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x070: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x090: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0A0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0B0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0C0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0D0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0E0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0F0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x100: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x110: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x120: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x130: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x140: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x150: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x160: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x170: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x180: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x190: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x1A0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x1B0: 00 00 00 00 00 00 00 00 2B 59 E1 3F 00 00 00 01
0x1C0: 01 00 82 FE 3F 81 3F 00 00 00 C3 DD 1F 00 00 00
0x1D0: 01 82 83 FE 7F 04 02 DE 1F 00 C3 1C 20 00 00 00
0x1E0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x1F0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 AA

fdisk -l shows that it sees the partition information on /dev/sdb now. (Compare with the first run of fdisk -l before creating the partitions.)

root@drizzle:/root # fdisk -l

Disk /dev/sda: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x0006e7e2

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1        1244     9992398+  83  Linux
/dev/sda2            1245        1305      489982+   5  Extended
/dev/sda5            1245        1305      489951   82  Linux swap / Solaris

Disk /dev/sdb: 2147 MB, 2147483648 bytes
255 heads, 63 sectors/track, 261 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x3fe1592b

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1         130     1044193+  82  Linux swap / Solaris
/dev/sdb2             131         261     1052257+  83  Linux

Having created the partitions, now we are ready to create the ext3 file system on the second partition, /dev/sdb2

root@drizzle:/root # mkfs.ext3 /dev/sdb2
mke2fs 1.41.3 (12-Oct-2008)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
65808 inodes, 263064 blocks
13153 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=272629760
9 block groups
32768 blocks per group, 32768 fragments per group
7312 inodes per group
Superblock backups stored on blocks: 
        32768, 98304, 163840, 229376

Writing inode tables: done                            
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 33 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.

Check on what /dev/sd* device files we have, and check what we have in /mnt – Then create the mount point directory /mnt/sdb2 and mount our new data partition there:

root@drizzle:/root # ls -al /dev/sd*
brw-rw---- 1 root disk 8,  0 2011-02-19 00:46 /dev/sda
brw-rw---- 1 root disk 8,  1 2011-02-19 00:46 /dev/sda1
brw-rw---- 1 root disk 8,  2 2011-02-19 00:46 /dev/sda2
brw-rw---- 1 root disk 8,  5 2011-02-19 00:46 /dev/sda5
brw-rw---- 1 root disk 8, 16 2011-02-19 01:38 /dev/sdb
brw-rw---- 1 root disk 8, 17 2011-02-19 01:38 /dev/sdb1
brw-rw---- 1 root disk 8, 18 2011-02-19 01:54 /dev/sdb2

root@drizzle:/root # cd /mnt

root@drizzle:/mnt # ls -al
total 12
drwxr-xr-x  3 root root 4096 2011-02-01 17:39 .
drwxr-xr-x 21 root root 4096 2011-01-21 10:57 ..
drwxr-xr-x  2 root root 4096 2011-02-01 17:39 hgfs

root@drizzle:/mnt # mkdir sdb2

root@drizzle:/mnt # ls -al
total 16
drwxr-xr-x  4 root root 4096 2011-02-19 01:59 .
drwxr-xr-x 21 root root 4096 2011-01-21 10:57 ..
drwxr-xr-x  2 root root 4096 2011-02-01 17:39 hgfs
drwxr-xr-x  2 root root 4096 2011-02-19 01:59 sdb2


root@drizzle:/mnt # mount /dev/sdb2 /mnt/sdb2

Take a look at the root directory of the new file system. Note that one directory, lost+found, is already there:

root@drizzle:/mnt # cd sdb2

root@drizzle:/mnt/sdb2 # ls -al
total 24
drwxr-xr-x 3 root root  4096 2011-02-19 01:54 .
drwxr-xr-x 4 root root  4096 2011-02-19 01:59 ..
drwx------ 2 root root 16384 2011-02-19 01:54 lost+found

root@drizzle:/mnt/sdb2 # mount
/dev/sda1 on / type ext3 (rw,errors=remount-ro)
tmpfs on /lib/init/rw type tmpfs (rw,nosuid,mode=0755)
proc on /proc type proc (rw,noexec,nosuid,nodev)
sysfs on /sys type sysfs (rw,noexec,nosuid,nodev)
procbususb on /proc/bus/usb type usbfs (rw)
udev on /dev type tmpfs (rw,mode=0755)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)
devpts on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=620)
none on /proc/fs/vmblock/mountPoint type vmblock (rw)
/dev/sdb2 on /mnt/sdb2 type ext3 (rw)


root@drizzle:/mnt/sdb2 # df
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/sda1              9835552   3564988   5770948  39% /
tmpfs                   365644         0    365644   0% /lib/init/rw
udev                     10240       668      9572   7% /dev
tmpfs                   365644         0    365644   0% /dev/shm
/dev/sdb2              1035692     34108    948972   4% /mnt/sdb2


root@drizzle:/root # vi /etc/fstab
(Add the following new line for /dev/sdb2 into /etc/fstab here.)
/dev/sdb2     /mnt/sdb2     ext3     defaults     0     2
root@drizzle:/root # cat /etc/fstab
# /etc/fstab: static file system information.
#
#                
proc            /proc           proc    defaults        0       0
/dev/sda1       /               ext3    errors=remount-ro 0       1
/dev/sda5       none            swap    sw              0       0
/dev/sdb2       /mnt/sdb2       ext3    defaults        0       2
/dev/hdc        /media/cdrom0   udf,iso9660 user,noauto     0       0
/dev/fd0        /media/floppy0  auto    rw,user,noauto  0       0

root@drizzle:/root # 

(At this point, I also created a file in /mnt/sdb2 called poem.txt and typed in a poem, to see if it will still be there after re-booting.)

==========================================================================

Ready to re-boot now and see if it gets auto-mounted and if everything is still there!

==========================================================================

After re-boot, with no further action on my part, we have:

jay@drizzle:/home/jay $ df
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/sda1              9835552   3565216   5770720  39% /
tmpfs                   365644         0    365644   0% /lib/init/rw
udev                     10240       668      9572   7% /dev
tmpfs                   365644         0    365644   0% /dev/shm
/dev/sdb2              1035692     34112    948968   4% /mnt/sdb2


jay@drizzle:/home/jay $ cd /mnt/sdb2

jay@drizzle:/mnt/sdb2 $ ls -al
total 28
drwxr-xr-x 3 root root  4096 2011-02-19 02:15 .
drwxr-xr-x 4 root root  4096 2011-02-19 01:59 ..
drwx------ 2 root root 16384 2011-02-19 01:54 lost+found
-rw-r--r-- 1 root root  1017 2011-02-19 02:15 poem.txt


jay@drizzle:/mnt/sdb2 $ cat poem.txt
Jabberwocky by Lewis Carroll

'Twas brillig, and the slithy toves
   Did gyre and gimble in the wabe:
All mimsy were the borogoves,
   And the mome raths outgrabe.

"Beware the Jabberwock, by son!
   The jaws that bite, the claws that catch!
Beware the Jub-Jub bird, and shun
   The frumious Bandersnatch!"

He took his vorpal sword in hand,
   Long time the Manxome foe he sought.
Then rested he by the Tum-Tum tree,
   And stood a while in thought.

And, as in uffish thought he stood,
   The Jabberwock, with eyes of flame
Came whiffling through the tulgey wood,
   And burbled as it came!

One, two!  One, two!  And through and through
   The vorpal blade went snicker-snack!
He left it dead, and with its head
   He went galumphing back!

"And hast thou slain the Jabberwock?
   Come to my arms, my beamish boy!
O frabjous day!  Callooh!  Callay!"
   He chortled in this joy.

'Twas brillig, and the slithy toves
   Did gyre and gimble in the wabe:
All mimsy were the borogoves,
   And the mome raths outgrabe.

jay@drizzle:/mnt/sdb2 $ 

==========================================================================

Now, back out in the host machine environment, examine how much space all the VM’s are using, and look at the directory containing the new virtual disk. We see that the new virtual disk is already taking up about 2.8 megabytes:

jay@frazzle: /home/jay $ du vmware
5756	vmware/dazzle/caches/GuestAppsCache/appData
36	vmware/dazzle/caches/GuestAppsCache/launchMenu
5796	vmware/dazzle/caches/GuestAppsCache
5800	vmware/dazzle/caches
4548780	vmware/dazzle
2716	vmware/com-disk-2
4876	vmware/fizzle/caches/GuestAppsCache/appData
36	vmware/fizzle/caches/GuestAppsCache/launchMenu
4916	vmware/fizzle/caches/GuestAppsCache
4920	vmware/fizzle/caches
5669940	vmware/fizzle
2044	vmware/drizzle/caches/GuestAppsCache/appData
24	vmware/drizzle/caches/GuestAppsCache/launchMenu
2072	vmware/drizzle/caches/GuestAppsCache
2076	vmware/drizzle/caches
4101164	vmware/drizzle
14322604	vmware

jay@frazzle: /home/jay $ cd vmware/com-disk-2

jay@frazzle: /home/jay/vmware/com-disk-2 $ ls -al
total 2720
drwxrwxrwx 2 jay jay    4096 2011-02-19 02:17 .
drwxr-xr-x 6 jay jay    4096 2011-02-19 00:13 ..
-rw-r--r-- 1 jay jay 2818048 2011-02-19 02:17 com-disk-2-s001.vmdk
-rw-r--r-- 1 jay jay   65536 2011-02-19 02:17 com-disk-2-s002.vmdk
-rw-r--r-- 1 jay jay     525 2011-02-19 01:38 com-disk-2.vmdk

jay@frazzle: /home/jay/vmware/com-disk-2 $ 

Work remaining to do (another day):

End of transcript.        ◄ Home        ◄ Back to Debian log