linux学习总结之磁盘管理
?
虛擬機(jī)操作:虛擬機(jī)——>設(shè)置——>硬盤——>添加——>確定
?
外接的磁盤一般放在/dev下,scsi設(shè)備一般以sd表示
?
ll /dev/sd*:顯示所有外接scsi設(shè)備
?
fdisk工具說明
fdisk /dev/sdb(設(shè)備絕對(duì)路徑):啟動(dòng)disk工具
[root@localhost ~]# fdisk /dev/sdb
Command (m for help):
?
輸入m可以查看幫助菜單
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???????????????刪除一個(gè)分區(qū)
?? l?? list known partition types??列出分區(qū)類型
?? m?? print this menu
?? n?? add a new partition???????????添加一個(gè)分區(qū)
?? o?? create a new empty DOS partition table
?? p?? print the partition table????? 查看分區(qū)
?? 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)
Command (m for help): p
Disk /dev/sdb: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 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: 0x0231ed13
?????????????????????????????????????????????????????????????????大小
?? Device Boot????? Start???????? End????? Blocks?? Id? System
/dev/sdb1?????????????? 1???????? 132???? 1060258+? 83? Linux
/dev/sdb2???????????? 133???????? 264???? 1060290?? 83? Linux
/dev/sdb3???????????? 265???????? 396???? 1060290?? 83? Linux
/dev/sdb4???????????? 397??????? 2094??? 13639185?? 83? Linux
p命令查看分區(qū)類型 該磁盤分了四個(gè)區(qū)
?
刪除分區(qū)3
Command (m for help): d
Partition number (1-4): 3
Command (m for help): p
Disk /dev/sdb: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 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: 0x0231ed13
?? Device Boot????? Start???????? End????? Blocks?? Id? System
/dev/sdb1?????????????? 1???????? 132???? 1060258+? 83? Linux
/dev/sdb2???????????? 133???????? 264???? 1060290?? 83? Linux
/dev/sdb4???????????? 397??????? 2094??? 13639185?? 83? Linux
?
添加分區(qū)3
Command (m for help): n
Command action????????????????????????選擇分區(qū)類型
?? e?? extended?????????????????????????????? 擴(kuò)展分區(qū)
?? p?? primary partition (1-4)???????? 主分區(qū)
p
Selected partition 3
First cylinder (265-2610, default 265):
Using default value 265
Last cylinder, +cylinders or +size{K,M,G} (265-396, default 396): +1G 分區(qū)大小
?
?
邏輯卷管理(摘抄)
邏輯卷的創(chuàng)建與掛載
1、創(chuàng)建物理卷
pvcreate /dev/sda5(設(shè)備) ——將設(shè)備變成物理卷(pv)
2、創(chuàng)建卷組
vgcreate vg01(卷組名) /dev/sdb5 (將設(shè)備添加到卷組里)
3、創(chuàng)建邏輯卷
lvcreate -L 50M -n lv01 vg01 ——在卷組vg01上創(chuàng)建一個(gè)名lv01的邏輯卷,大小為50M
4、查看物理卷、卷組及邏輯卷
pvs、vgs、lvs 詳細(xì)查看 pvdisplay、vgdisplay、lvdisplay
5、創(chuàng)建文件系統(tǒng)
mkfs.ext4 /dev/vg01/lv01
6、掛載使用
mount /dev/vg01/lv01 /u01
df -h 查看掛載情況
7、刪除邏輯卷
lvremove /dev/vg01/lv01
8、刪除卷組
vgremove vg01
9、刪除物理卷
pvremove /dev/sda5
?
?
邏輯卷的擴(kuò)展
1、當(dāng)卷組足夠大時(shí)
1)lvextend -L 1G /dev/mapper/vg01-lv01 ——直接擴(kuò)展邏輯卷大小
注意:-l +100 表示擴(kuò)展100個(gè)pe大小,即100*4M=400M的空間
2)resize2fs /dev/mapper/vg01-lv01 ——在線同步文件系統(tǒng)
3)查看
2、當(dāng)卷組空間不夠擴(kuò)展邏輯卷時(shí)
1)添加新的分區(qū)或者硬盤到系統(tǒng)中
2)pvcreate /dev/sda6 ——?jiǎng)?chuàng)建一個(gè)物理卷
3)vgextend vg01 /dev/sda6 ——將新的pv添加到卷組中
4)lvextend -L 1G /dev/mapper/vg01-lv01
5)resize2fs /dev/mapper/vg01-lv01
邏輯卷的縮小:
1、umount /u01 ——卸載邏輯卷
2、e2fsck -f /dev/vg01/lv01 ——檢測(cè)文件系統(tǒng)數(shù)據(jù)
3、resize2fs /dev/mapper/vg01-lv01 500M ——減小文件系統(tǒng),減小到500M
4、lvreduce -L 500M /dev/mapper/vg01-lv01 ——減小邏輯卷
5、mount /dev/mapper/vg01-lv01 /u01——掛載測(cè)試
?
?
總結(jié)
以上是生活随笔為你收集整理的linux学习总结之磁盘管理的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: linux命令行操作之文件操作总结
- 下一篇: linux学习总结之基本命令