This post is about how to add a file system in a linux guest running on VBox (or any Linux host)
1. Stop the Guest, and add the hard disk to the VBox image, under Settings > Storage > Controller
2. Then start the VM, login as root and confirm that the device is listed under fdisk -l
[root@localhost ~]# fdisk -l
Disk /dev/hda: 12.8 GB, 12884901888 bytes
255 heads, 63 sectors/track, 1566 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/hda1 * 1 1350 10843843+ 83 Linux
/dev/hda2 1351 1566 1735020 82 Linux swap / Solaris
Disk /dev/hdb: 12.8 GB, 12884901888 bytes
255 heads, 63 sectors/track, 1566 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/hdb1 * 1 1566 12578863+ 83 Linux
Disk /dev/hdd: 10.7 GB, 10737418240 bytes
16 heads, 63 sectors/track, 20805 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
Disk /dev/hdd doesn't contain a valid partition table
3. Create the physical volume with pvcreate:
[root@localhost ~]# pvcreate /dev/hdd Physical volume "/dev/hdd" successfully created
4. Create a volume group vg00 with vgcreate:
[root@localhost ~]# vgcreate vg00 /dev/hdd
Volume group "vg00" successfully created
5. Create a logical volume with lvcreate:
[root@localhost ~]# lvcreate -L 9.5g -n apps-fs vg00
Logical volume "apps-fs" created
6. Now review with pvs, vgs, lvs:
[root@localhost ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/hdd vg00 lvm2 a- 10.00G 10.00G
[root@localhost ~]# vgs
VG #PV #LV #SN Attr VSize VFree
vg00 1 0 0 wz--n- 10.00G 10.00G
[root@localhost ~]# lvs
LV VG Attr LSize Origin Snap% Move Log Copy% Convert
apps-fs vg00 -wi-a- 9.50G
7. Now make a file system with mkfs...
[root@localhost ~]# mkfs.ext3 /dev/vg00/apps-fs
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
1245184 inodes, 2490368 blocks
124518 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2550136832
76 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 25 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
8. Then create a directory to attach the file system:
[root@localhost /]# mkdir -m 755 /u01
[root@localhost /]# ls -ld /u01
drwxr-xr-x 2 root root 4096 Apr 10 10:38 /u01
9. Now add an entry in /etc/fstab to auto-mount the new file system at reboot:
[root@localhost /]# vi /etc/fstab
[root@localhost /]# cat /etc/fstab
LABEL=/ / ext3 defaults 1 1
LABEL=/home /home ext3 defaults 1 2
...
/dev/vg00/app-fs /u01 ext3 defaults,usrquota 0 2
10. Test to make sure there are no errors in the /etc/fstab file with "mount -a". If there is no output, then there are no errors:
[root@localhost /]# mount -a
[root@localhost /]#
[root@localhost /]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/hda1 11G 2.3G 7.3G 24% /
/dev/hdb1 12G 7.2G 3.9G 66% /home
tmpfs 1.8G 284M 1.5G 17% /dev/shm
Shared_VM_ODI12c 215G 141G 74G 66% /media/sf_Shared_VM_ODI12c
/dev/mapper/vg00-apps--fs 9.4G 150M 8.8G 2% /u01
No comments:
Post a Comment