最近实施的一个项目,除开linux操作系统不用自己安装,所有操作都需要自己亲力亲为,对于linux命令不是很熟练的我,通过各种查资料终于把最开始的磁盘挂载和扩充搞定,留下笔记,供大家参考。
逻辑磁盘挂载方法一(PVS分盘)
[root@localhost ~]# pvs PV VG Fmt Attr PSize PFree /dev/sda2 VolGroup lvm2 a--u 31.51g 0 /dev/sdb vg_test lvm2 a--u 32.00g 32.00g [root@localhost ~]# pvresize /dev/sdb Physical volume "/dev/sdb" changed 1 physical volume(s) resized / 0 physical volume(s) not resized [root@localhost ~]# pvs PV VG Fmt Attr PSize PFree /dev/sda2 VolGroup lvm2 a--u 31.51g 0 /dev/sdb vg_test lvm2 a--u 100.00g 100.00g [root@localhost ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/VolGroup-lv_root 28G 12G 16G 43% / tmpfs 3.9G 76K 3.9G 1% /dev/shm /dev/sda1 477M 74M 378M 17% /boot #esb_lv自定义,vg_test 与 /dev/sdb对应上 [root@localhost ~]# lvcreate -L 100G -n esb_lv vg_test Logical volume "esb_lv" created. #格式化对应的逻辑目录 [root@localhost ~]#mkfs.ext4 /dev/vg_test/esb_lv mke2fs 1.41.12 (17-May-2010) Discarding device blocks: done Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) Stride=0 blocks, Stripe width=0 blocks 5898240 inodes, 23592960 blocks 1179648 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=4294967296 720 block groups 32768 blocks per group, 32768 fragments per group 8192 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 4096000, 7962624, 11239424, 20480000
Writing inode tables: done Creating journal (32768 blocks): done Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 29 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override. #在/etc/fstab文件中增加一行 /dev/mapper/vg_test-esb_lv /home ext4 defaults 0 0 [root@localhost ~]# vi /etc/fstab [root@localhost ~]#mount /home [root@localhost ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/VolGroup-lv_root 28G 12G 16G 43% / tmpfs 3.9G 76K 3.9G 1% /dev/shm /dev/sda1 477M 74M 378M 17% /boot /dev/mapper/vg_test-esb_lv 89G 56M 84G 1% /home [root@localhost ~]# |
逻辑磁盘挂载方法2(fdisk分盘)
[root@localhost ~]#fdisk -l
Disk /dev/sda: 34.4 GB, 34359738368 bytes 255 heads, 63 sectors/track, 4177 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x0007706c
Device Boot Start End Blocks Id System /dev/sda1 * 1 64 512000 83 Linux Partition 1 does not end on cylinder boundary. /dev/sda2 64 4178 33041408 8e Linux LVM
Disk /dev/sdb: 214.7 GB, 214748364800 bytes 255 heads, 63 sectors/track, 26108 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00000000
Disk /dev/mapper/VolGroup-lv_root: 30.4 GB, 30396121088 bytes 255 heads, 63 sectors/track, 3695 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00000000
Disk /dev/mapper/VolGroup-lv_swap: 3435 MB, 3435134976 bytes 255 heads, 63 sectors/track, 417 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00000000
[root@localhost ~]# 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 0xa11619cb. 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)
WARNING: DOS-compatible mode is deprecated. It's strongly recommended to switch off the mode (command 'c') and change display units to sectors (command 'u').
Command (m for help):n Command action e extended p primary partition (1-4) p Partition number (1-4): 1 First cylinder (1-26108, default 1): 1 Last cylinder, +cylinders or +size{K,M,G} (1-26108, default 26108): Using default value 26108
Command (m for help): p
Disk /dev/sdb: 214.7 GB, 214748364800 bytes 255 heads, 63 sectors/track, 26108 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0xa11619cb
Device Boot Start End Blocks Id System /dev/sdb1 1 26108 209712478+ 83 Linux
Command (m for help): w The partition table has been altered!
Calling ioctl() to re-read partition table. Syncing disks. [root@localhost ~]# pvs PV VG Fmt Attr PSize PFree /dev/sda2 VolGroup lvm2 a--u 31.51g 0 [root@localhost ~]# fdisk -l
Disk /dev/sda: 34.4 GB, 34359738368 bytes 255 heads, 63 sectors/track, 4177 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x0007706c
Device Boot Start End Blocks Id System /dev/sda1 * 1 64 512000 83 Linux Partition 1 does not end on cylinder boundary. /dev/sda2 64 4178 33041408 8e Linux LVM
Disk /dev/sdb: 214.7 GB, 214748364800 bytes 255 heads, 63 sectors/track, 26108 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0xa11619cb
Device Boot Start End Blocks Id System /dev/sdb1 1 26108 209712478+ 83 Linux
Disk /dev/mapper/VolGroup-lv_root: 30.4 GB, 30396121088 bytes 255 heads, 63 sectors/track, 3695 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00000000
Disk /dev/mapper/VolGroup-lv_swap: 3435 MB, 3435134976 bytes 255 heads, 63 sectors/track, 417 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00000000
[root@localhost ~]# mkfs -t ext3 /dev/sdb1 mke2fs 1.41.12 (17-May-2010) Discarding device blocks: done Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) Stride=0 blocks, Stripe width=0 blocks 13107200 inodes, 52428119 blocks 2621405 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=4294967296 1600 block groups 32768 blocks per group, 32768 fragments per group 8192 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 4096000, 7962624, 11239424, 20480000, 23887872
Writing inode tables: done Creating journal (32768 blocks): done Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 39 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override. [root@localhost ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/VolGroup-lv_root 28G 12G 16G 43% / tmpfs 7.8G 76K 7.8G 1% /dev/shm /dev/sda1 477M 74M 378M 17% /boot [root@localhost ~]#mount /dev/sdb1 /home [root@localhost ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/VolGroup-lv_root 28G 12G 16G 43% / tmpfs 7.8G 76K 7.8G 1% /dev/shm /dev/sda1 477M 74M 378M 17% /boot /dev/sdb1 197G 188M 187G 1% /home [root@localhost ~]# vi /etc/fstab #增加一条记录 /dev/sdb1 /home ext3 defaults 1 2 [root@localhost ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/VolGroup-lv_root 28G 12G 16G 43% / tmpfs 7.8G 76K 7.8G 1% /dev/shm /dev/sda1 477M 74M 378M 17% /boot /dev/sdb1 197G 188M 187G 1% /home |
在已有目录上,磁盘空间不够,需要扩充目录的空间大小
[root@esbdb ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/VolGroup-lv_root 28G 12G 15G 44% / tmpfs 8.0G 2.1G 6.0G 26% /dev/shm /dev/sda1 477M 74M 378M 17% /boot /dev/mapper/vg_test-esb_lv 89G 72G 13G 86% /home [root@esbdb ~]# pvs PV VG Fmt Attr PSize PFree /dev/sda2 VolGroup lvm2 a--u 31.51g 0 /dev/sdb vg_test lvm2 a--u 100.00g 10.00g [root@esbdb ~]# lvextend -L +8G /dev/mapper/vg_test-esb_lv Size of logical volume vg_test/esb_lv changed from 90.00 GiB (23040 extents) to 98.00 GiB (25088 extents). Logical volume esb_lv successfully resized. [root@esbdb ~]# resize2fs -p /dev/mapper/vg_test-esb_lv resize2fs 1.41.12 (17-May-2010) Filesystem at /dev/mapper/vg_test-esb_lv is mounted on /home; on-line resizing required old desc_blocks = 6, new_desc_blocks = 7 Performing an on-line resize of /dev/mapper/vg_test-esb_lv to 25690112 (4k) blocks. The filesystem on /dev/mapper/vg_test-esb_lv is now 25690112 blocks long.
[root@esbdb ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/VolGroup-lv_root 28G 12G 15G 44% / tmpfs 8.0G 2.1G 6.0G 26% /dev/shm /dev/sda1 477M 74M 378M 17% /boot /dev/mapper/vg_test-esb_lv 97G 72G 21G 79% /home [root@esbdb ~]# |
所有命令都是自己操作过的记录,对于linux新手应该有一定的帮助的。各位不喜勿喷。