1、为主机新增两块30GB的SCSI硬盘
[root@localhost ~]# fdisk -l /dev/sda
[root@localhost ~]# fdisk -l /dev/sda
磁盘 /dev/sda:42.9 GB, 42949672960 字节,83886080 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:dos
磁盘标识符:0x000a8e09
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:dos
磁盘标识符:0x000a8e09
设备 Boot Start End Blocks Id System
/dev/sda1 * 2048 2099199 1048576 83 Linux
/dev/sda2 2099200 83886079 40893440 8e Linux LVM
[root@localhost ~]# fdisk -l /dev/sdb
/dev/sda1 * 2048 2099199 1048576 83 Linux
/dev/sda2 2099200 83886079 40893440 8e Linux LVM
[root@localhost ~]# fdisk -l /dev/sdb
磁盘 /dev/sdb:32.2 GB, 32212254720 字节,62914560 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
[root@localhost ~]# fdisk -l /dev/sdc
磁盘 /dev/sdc:32.2 GB, 32212254720 字节,62914560 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
2、划分3个主分区,各5GB,剩余空间作为扩展分区
命令(输入 m 获取帮助):p
命令(输入 m 获取帮助):p
磁盘 /dev/sdb:32.2 GB, 32212254720 字节,62914560 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:dos
磁盘标识符:0xbd5c2535
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:dos
磁盘标识符:0xbd5c2535
设备 Boot Start End Blocks Id System
/dev/sdb1 2048 10487807 5242880 83 Linux
/dev/sdb2 10487808 20973567 5242880 83 Linux
/dev/sdb3 20973568 31459327 5242880 83 Linux
/dev/sdb4 31459328 62914559 15727616 5 Extended
/dev/sdb1 2048 10487807 5242880 83 Linux
/dev/sdb2 10487808 20973567 5242880 83 Linux
/dev/sdb3 20973568 31459327 5242880 83 Linux
/dev/sdb4 31459328 62914559 15727616 5 Extended
3、在扩展分区中建立2个逻辑分区,容量分别为2GB、10GB
设备 Boot Start End Blocks Id System
/dev/sdb1 2048 10487807 5242880 83 Linux
/dev/sdb2 10487808 20973567 5242880 83 Linux
/dev/sdb3 20973568 31459327 5242880 83 Linux
/dev/sdb4 31459328 62914559 15727616 5 Extended
/dev/sdb5 31461376 35655679 2097152 83 Linux
/dev/sdb6 35657728 56629247 10485760 83 Linux
4、将第一个逻辑分区的类型改为swap
设备 Boot Start End Blocks Id System
/dev/sdb1 2048 10487807 5242880 83 Linux
/dev/sdb2 10487808 20973567 5242880 83 Linux
/dev/sdb3 20973568 31459327 5242880 83 Linux
/dev/sdb4 31459328 62914559 15727616 5 Extended
/dev/sdb5 31461376 35655679 2097152 83 Linux
/dev/sdb6 35657728 56629247 10485760 83 Linux
4、将第一个逻辑分区的类型改为swap
命令(输入 m 获取帮助):t
分区号 (1-6,默认 6):5
Hex 代码(输入 L 列出所有代码):82
已将分区“Linux”的类型更改为“Linux swap / Solaris”
分区号 (1-6,默认 6):5
Hex 代码(输入 L 列出所有代码):82
已将分区“Linux”的类型更改为“Linux swap / Solaris”
命令(输入 m 获取帮助):p
磁盘 /dev/sdb:32.2 GB, 32212254720 字节,62914560 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:dos
磁盘标识符:0xbd5c2535
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:dos
磁盘标识符:0xbd5c2535
设备 Boot Start End Blocks Id System
/dev/sdb1 2048 10487807 5242880 83 Linux
/dev/sdb2 10487808 20973567 5242880 83 Linux
/dev/sdb3 20973568 31459327 5242880 83 Linux
/dev/sdb4 31459328 62914559 15727616 5 Extended
/dev/sdb5 31461376 35655679 2097152 82 Linux swap / Solaris
/dev/sdb6 35657728 56629247 10485760 83 Linux
/dev/sdb1 2048 10487807 5242880 83 Linux
/dev/sdb2 10487808 20973567 5242880 83 Linux
/dev/sdb3 20973568 31459327 5242880 83 Linux
/dev/sdb4 31459328 62914559 15727616 5 Extended
/dev/sdb5 31461376 35655679 2097152 82 Linux swap / Solaris
/dev/sdb6 35657728 56629247 10485760 83 Linux
5、将第一个主分区格式化为ext4
[root@localhost ~]# mkfs -t ext4 /dev/sdb1
6、将第二个主分区格式化为xfs
[root@localhost ~]# mkfs -t xfs /dev/sdb2
7、将第三个主分区格式化为FAT32
[root@localhost ~]# mkfs -t vfat -F 32 /dev/sdb3
mkfs.fat 3.0.20 (12 Jun 2013)
8、创建 /data1 /data2 /data3
[root@localhost ~]# mkdir /{data1,data2,data3}
9、将第一个主分区挂载到/data1,在目录中创建文件测试,并实现 /etc/fstab
[root@localhost ~]# mount /dev/sdb1 /data1
[root@localhost ~]# vim /etc/fstab
/dev/sdb1 /data1 ext4 defaults 12
[root@localhost ~]# mkfs -t ext4 /dev/sdb1
6、将第二个主分区格式化为xfs
[root@localhost ~]# mkfs -t xfs /dev/sdb2
7、将第三个主分区格式化为FAT32
[root@localhost ~]# mkfs -t vfat -F 32 /dev/sdb3
mkfs.fat 3.0.20 (12 Jun 2013)
8、创建 /data1 /data2 /data3
[root@localhost ~]# mkdir /{data1,data2,data3}
9、将第一个主分区挂载到/data1,在目录中创建文件测试,并实现 /etc/fstab
[root@localhost ~]# mount /dev/sdb1 /data1
[root@localhost ~]# vim /etc/fstab
/dev/sdb1 /data1 ext4 defaults 12
[root@localhost ~]# df -i /dev/sdb1
文件系统 Inode 已用(I) 可用(I) 已用(I)% 挂载点
/dev/sdb1 327680 11 327669 1% /data1
10、将第二个主分区挂载到/data2,在目录中创建文件测试,并实现 /etc/fstab
[root@localhost ~]# mount /dev/sdb2 /data3
[root@localhost ~]# vim /etc/fstab
/dev/sdb2 /data2 xfs defaults 12
[root@localhost ~]# df -i /dev/sdb2
文件系统 Inode 已用(I) 可用(I) 已用(I)% 挂载点
/dev/sdb2 2621440 3 2621437 1% /data3
11、将第二个主分区挂载到/data3,在目录中创建文件测试,并基于UUID实现 /etc/fstab
[root@localhost ~]# mount /dev/sdb3 /data3
[root@localhost ~]# blkid /dev/sdb3
/dev/sdb3: UUID="B5B1-C817" TYPE="vfat"
[root@localhost ~]# blkid /dev/sdb3 >> /etc/fstab
[root@localhost ~]# vim /etc/fstab
/dev/sdb3: UUID="B5B1-C817" TYPE="vfat"
12、将第一个逻辑分区格式化swap格式,将swap分区扩展,测试查看
[root@localhost ~]# mkswap /dev/sdb5
正在设置交换空间版本 1,大小 = 2097148 KiB
无标签,UUID=3207f938-49dc-4bba-b075-de6d4a801027
[root@localhost ~]# swapon -s
文件名 类型 大小 已用 权限
/dev/dm-1 partition 2097148 0 -1
[root@localhost ~]# cat /proc/meminfo | grep -i "swaptotal"
SwapTotal: 2097148 kB
[root@localhost ~]# swapon /dev/sdb5
[root@localhost ~]# swapon -s
文件名 类型 大小 已用 权限
/dev/dm-1 partition 2097148 0 -1
/dev/sdb5 partition 2097148 0 -2
[root@localhost ~]# cat /proc/meminfo | grep -i "swaptotal"
SwapTotal: 4194296 kB
13、通过xftp等工具将linux.iso 传到linux虚拟机中,并挂载查看内容
文件系统 Inode 已用(I) 可用(I) 已用(I)% 挂载点
/dev/sdb1 327680 11 327669 1% /data1
10、将第二个主分区挂载到/data2,在目录中创建文件测试,并实现 /etc/fstab
[root@localhost ~]# mount /dev/sdb2 /data3
[root@localhost ~]# vim /etc/fstab
/dev/sdb2 /data2 xfs defaults 12
[root@localhost ~]# df -i /dev/sdb2
文件系统 Inode 已用(I) 可用(I) 已用(I)% 挂载点
/dev/sdb2 2621440 3 2621437 1% /data3
11、将第二个主分区挂载到/data3,在目录中创建文件测试,并基于UUID实现 /etc/fstab
[root@localhost ~]# mount /dev/sdb3 /data3
[root@localhost ~]# blkid /dev/sdb3
/dev/sdb3: UUID="B5B1-C817" TYPE="vfat"
[root@localhost ~]# blkid /dev/sdb3 >> /etc/fstab
[root@localhost ~]# vim /etc/fstab
/dev/sdb3: UUID="B5B1-C817" TYPE="vfat"
12、将第一个逻辑分区格式化swap格式,将swap分区扩展,测试查看
[root@localhost ~]# mkswap /dev/sdb5
正在设置交换空间版本 1,大小 = 2097148 KiB
无标签,UUID=3207f938-49dc-4bba-b075-de6d4a801027
[root@localhost ~]# swapon -s
文件名 类型 大小 已用 权限
/dev/dm-1 partition 2097148 0 -1
[root@localhost ~]# cat /proc/meminfo | grep -i "swaptotal"
SwapTotal: 2097148 kB
[root@localhost ~]# swapon /dev/sdb5
[root@localhost ~]# swapon -s
文件名 类型 大小 已用 权限
/dev/dm-1 partition 2097148 0 -1
/dev/sdb5 partition 2097148 0 -2
[root@localhost ~]# cat /proc/meminfo | grep -i "swaptotal"
SwapTotal: 4194296 kB
13、通过xftp等工具将linux.iso 传到linux虚拟机中,并挂载查看内容
[root@localhost ~]# ls
anaconda-ks.cfg initial-setup-ks.cfg linux.iso 公共 模板 视频 图片 文档 下载 音乐 桌面
[root@localhost ~]# mkdir /iso
[root@localhost ~]# mount /root/linux.iso /iso
mount: /dev/loop0 写保护,将以只读方式挂载
[root@localhost ~]# ls /iso
manifest.txt VMwareTools-10.3.2-9925305.tar.gz vmware-tools-upgrader-64
run_upgrader.sh vmware-tools-upgrader-32
anaconda-ks.cfg initial-setup-ks.cfg linux.iso 公共 模板 视频 图片 文档 下载 音乐 桌面
[root@localhost ~]# mkdir /iso
[root@localhost ~]# mount /root/linux.iso /iso
mount: /dev/loop0 写保护,将以只读方式挂载
[root@localhost ~]# ls /iso
manifest.txt VMwareTools-10.3.2-9925305.tar.gz vmware-tools-upgrader-64
run_upgrader.sh vmware-tools-upgrader-32
14、基于文件方式将SWAP扩大500M
[root@localhost ~]# cat /proc/meminfo |grep "SwapTotal"
SwapTotal: 4194296 kB
[root@localhost ~]# dd if=/dev/zero of=/swapfile bs=1M count=500
记录了500+0 的读入
记录了500+0 的写出
524288000字节(524 MB)已复制,4.54386 秒,115 MB/秒
SwapTotal: 4194296 kB
[root@localhost ~]# dd if=/dev/zero of=/swapfile bs=1M count=500
记录了500+0 的读入
记录了500+0 的写出
524288000字节(524 MB)已复制,4.54386 秒,115 MB/秒
15、利用dd命令将光盘内容制作成iso镜像文件
法一:mkdir /media/cdrom
mount /dev/cdrom /media/cdrom
ls /media/cdrom
dd if=/dev/cdrom of=/root/linux-1.iso
法二:
cp /dev/cdrom /root/linux-2.iso
mount /dev/cdrom /media/cdrom
ls /media/cdrom
dd if=/dev/cdrom of=/root/linux-1.iso
法二:
cp /dev/cdrom /root/linux-2.iso
16、查看磁盘的使用情况
df-Th 或者 df -i /dev/sdb
17、利用parted命令将上述分区过程对另一个硬盘重做一遍
[root@localhost ~]# parted -l
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sda: 42.9GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sda: 42.9GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:
Number Start End Size Type File system 标志
1 1049kB 1075MB 1074MB primary xfs 启动
2 1075MB 42.9GB 41.9GB primary lvm
1 1049kB 1075MB 1074MB primary xfs 启动
2 1075MB 42.9GB 41.9GB primary lvm
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdb: 32.2GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:
Number Start End Size Type File system 标志
1 1049kB 5370MB 5369MB primary lvm
2 5370MB 10.7GB 5369MB primary lvm
3 10.7GB 16.1GB 5369MB primary lvm
4 16.1GB 21.5GB 5369MB primary lvm
1 1049kB 5370MB 5369MB primary lvm
2 5370MB 10.7GB 5369MB primary lvm
3 10.7GB 16.1GB 5369MB primary lvm
4 16.1GB 21.5GB 5369MB primary lvm
错误: /dev/sdc: unrecognised disk label
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdc: 32.2GB
Sector size (logical/physical): 512B/512B
Partition Table: unknown
Disk Flags:
Model: Linux device-mapper (linear) (dm)
Disk /dev/mapper/myvg-mylv: 12.9GB
Sector size (logical/physical): 512B/512B
Partition Table: loop
Disk Flags:
Disk /dev/mapper/myvg-mylv: 12.9GB
Sector size (logical/physical): 512B/512B
Partition Table: loop
Disk Flags:
Number Start End Size File system 标志
1 0.00B 12.9GB 12.9GB xfs
1 0.00B 12.9GB 12.9GB xfs
Model: Linux device-mapper (linear) (dm)
Disk /dev/mapper/centos-swap: 2147MB
Sector size (logical/physical): 512B/512B
Partition Table: loop
Disk Flags:
Number Start End Size File system 标志
1 0.00B 2147MB 2147MB linux-swap(v1)
1 0.00B 2147MB 2147MB linux-swap(v1)
Model: Linux device-mapper (linear) (dm)
Disk /dev/mapper/centos-root: 39.7GB
Sector size (logical/physical): 512B/512B
Partition Table: loop
Disk Flags:
Number Start End Size File system 标志
1 0.00B 39.7GB 39.7GB xfs
1 0.00B 39.7GB 39.7GB xfs
警告: 无法以读写方式打开 /dev/sr0 (只读文件系统)。/dev/sr0 已按照只读方式打开。
Model: NECVMWar VMware IDE CDR10 (scsi)
Disk /dev/sr0: 4521MB
Sector size (logical/physical): 2048B/2048B
Partition Table: msdos
Disk Flags:
Number Start End Size Type File system 标志
2 4751kB 41.6MB 36.8MB primary
2 4751kB 41.6MB 36.8MB primary
[root@localhost ~]# parted /dev/sdc
GNU Parted 3.1
使用 /dev/sdc
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted)
(parted) q
[root@localhost ~]# parted /dev/sdc
GNU Parted 3.1
使用 /dev/sdc
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) help
align-check TYPE N check partition N for TYPE(min|opt) alignment
help [COMMAND] print general help, or help on COMMAND
mklabel,mktable LABEL-TYPE create a new disklabel (partition table)
mkpart PART-TYPE [FS-TYPE] START END make a partition
name NUMBER NAME name partition NUMBER as NAME
print [devices|free|list,all|NUMBER] display the partition table, available devices, free
space, all found partitions, or a particular partition
quit exit program
rescue START END rescue a lost partition near START and END
rm NUMBER delete partition NUMBER
select DEVICE choose the device to edit
disk_set FLAG STATE change the FLAG on selected device
disk_toggle [FLAG] toggle the state of FLAG on selected device
set NUMBER FLAG STATE change the FLAG on partition NUMBER
toggle [NUMBER [FLAG]] toggle the state of FLAG on partition NUMBER
unit UNIT set the default unit to UNIT
version display the version number and copyright information of
GNU Parted
(parted) mklabel
新的磁盘标签类型?
aix amiga bsd dvh gpt loop mac msdos pc98 sun
新的磁盘标签类型? gpt
(parted) p
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdc: 32.2GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name 标志
(parted) gpt
align-check TYPE N check partition N for TYPE(min|opt) alignment
help [COMMAND] print general help, or help on COMMAND
mklabel,mktable LABEL-TYPE create a new disklabel (partition table)
mkpart PART-TYPE [FS-TYPE] START END make a partition
name NUMBER NAME name partition NUMBER as NAME
print [devices|free|list,all|NUMBER] display the partition table, available devices, free
space, all found partitions, or a particular partition
quit exit program
rescue START END rescue a lost partition near START and END
rm NUMBER delete partition NUMBER
select DEVICE choose the device to edit
disk_set FLAG STATE change the FLAG on selected device
disk_toggle [FLAG] toggle the state of FLAG on selected device
set NUMBER FLAG STATE change the FLAG on partition NUMBER
toggle [NUMBER [FLAG]] toggle the state of FLAG on partition NUMBER
unit UNIT set the default unit to UNIT
version display the version number and copyright information of
GNU Parted
(parted) mkpart
分区名称? []? part1
文件系统类型? [ext2]? ext4
起始点? 5G
结束点? 10G
(parted) mkpart
分区名称? []? part2
文件系统类型? [ext2]? ext4
起始点? 1G
结束点? 5G
(parted) mkpart
分区名称? []? part3
文件系统类型? [ext2]? ext4
起始点? 10G
结束点? -1
(parted) p
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdc: 32.2GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
align-check TYPE N check partition N for TYPE(min|opt) alignment
help [COMMAND] print general help, or help on COMMAND
mklabel,mktable LABEL-TYPE create a new disklabel (partition table)
mkpart PART-TYPE [FS-TYPE] START END make a partition
name NUMBER NAME name partition NUMBER as NAME
print [devices|free|list,all|NUMBER] display the partition table, available devices, free
space, all found partitions, or a particular partition
quit exit program
rescue START END rescue a lost partition near START and END
rm NUMBER delete partition NUMBER
select DEVICE choose the device to edit
disk_set FLAG STATE change the FLAG on selected device
disk_toggle [FLAG] toggle the state of FLAG on selected device
set NUMBER FLAG STATE change the FLAG on partition NUMBER
toggle [NUMBER [FLAG]] toggle the state of FLAG on partition NUMBER
unit UNIT set the default unit to UNIT
version display the version number and copyright information of
GNU Parted
(parted) mkpart
分区名称? []? part1
文件系统类型? [ext2]? ext4
起始点? 5G
结束点? 10G
(parted) mkpart
分区名称? []? part2
文件系统类型? [ext2]? ext4
起始点? 1G
结束点? 5G
(parted) mkpart
分区名称? []? part3
文件系统类型? [ext2]? ext4
起始点? 10G
结束点? -1
(parted) p
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdc: 32.2GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name 标志
2 1000MB 5000MB 3999MB part2
1 5000MB 10.0GB 5001MB part1
3 10.0GB 32.2GB 22.2GB part3
2 1000MB 5000MB 3999MB part2
1 5000MB 10.0GB 5001MB part1
3 10.0GB 32.2GB 22.2GB part3
(parted) q
信息: You may need to update /etc/fstab.
信息: You may need to update /etc/fstab.
[root@localhost ~]# parted -l
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sda: 42.9GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sda: 42.9GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:
Number Start End Size Type File system 标志
1 1049kB 1075MB 1074MB primary xfs 启动
2 1075MB 42.9GB 41.9GB primary lvm
1 1049kB 1075MB 1074MB primary xfs 启动
2 1075MB 42.9GB 41.9GB primary lvm
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdb: 32.2GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:
Number Start End Size Type File system 标志
1 1049kB 5370MB 5369MB primary lvm
2 5370MB 10.7GB 5369MB primary lvm
3 10.7GB 16.1GB 5369MB primary lvm
4 16.1GB 21.5GB 5369MB primary lvm
1 1049kB 5370MB 5369MB primary lvm
2 5370MB 10.7GB 5369MB primary lvm
3 10.7GB 16.1GB 5369MB primary lvm
4 16.1GB 21.5GB 5369MB primary lvm
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdc: 32.2GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name 标志
2 1000MB 5000MB 3999MB part2
1 5000MB 10.0GB 5001MB part1
3 10.0GB 32.2GB 22.2GB part3
2 1000MB 5000MB 3999MB part2
1 5000MB 10.0GB 5001MB part1
3 10.0GB 32.2GB 22.2GB part3
Model: Linux device-mapper (linear) (dm)
Disk /dev/mapper/myvg-mylv: 12.9GB
Sector size (logical/physical): 512B/512B
Partition Table: loop
Disk Flags:
Number Start End Size File system 标志
1 0.00B 12.9GB 12.9GB xfs
1 0.00B 12.9GB 12.9GB xfs
Model: Linux device-mapper (linear) (dm)
Disk /dev/mapper/centos-swap: 2147MB
Sector size (logical/physical): 512B/512B
Partition Table: loop
Disk Flags:
Number Start End Size File system 标志
1 0.00B 2147MB 2147MB linux-swap(v1)
1 0.00B 2147MB 2147MB linux-swap(v1)
Model: Linux device-mapper (linear) (dm)
Disk /dev/mapper/centos-root: 39.7GB
Sector size (logical/physical): 512B/512B
Partition Table: loop
Disk Flags:
Number Start End Size File system 标志
1 0.00B 39.7GB 39.7GB xfs
1 0.00B 39.7GB 39.7GB xfs
警告: 无法以读写方式打开 /dev/sr0 (只读文件系统)。/dev/sr0 已按照只读方式打开。
Model: NECVMWar VMware IDE CDR10 (scsi)
Disk /dev/sr0: 4521MB
Sector size (logical/physical): 2048B/2048B
Partition Table: msdos
Disk Flags:
Number Start End Size Type File system 标志
2 4751kB 41.6MB 36.8MB primary
2 4751kB 41.6MB 36.8MB primary
[root@localhost ~]# parted /dev/sdc
GNU Parted 3.1
使用 /dev/sdc
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) help
align-check TYPE N check partition N for TYPE(min|opt) alignment
help [COMMAND] print general help, or help on COMMAND
mklabel,mktable LABEL-TYPE create a new disklabel (partition table)
mkpart PART-TYPE [FS-TYPE] START END make a partition
name NUMBER NAME name partition NUMBER as NAME
print [devices|free|list,all|NUMBER] display the partition table, available devices, free
space, all found partitions, or a particular partition
quit exit program
rescue START END rescue a lost partition near START and END
rm NUMBER delete partition NUMBER
select DEVICE choose the device to edit
disk_set FLAG STATE change the FLAG on selected device
disk_toggle [FLAG] toggle the state of FLAG on selected device
set NUMBER FLAG STATE change the FLAG on partition NUMBER
toggle [NUMBER [FLAG]] toggle the state of FLAG on partition NUMBER
unit UNIT set the default unit to UNIT
version display the version number and copyright information of
GNU Parted
(parted) mklabel
新的磁盘标签类型? gpt
警告: The existing disk label on /dev/sdc will be destroyed and all data on this disk will be lost. Do
you want to continue?
是/Yes/否/No? y
(parted) mkpart
分区名称? []? part1
文件系统类型? [ext2]? ext4
起始点? 1G
结束点? 5G
(parted) mkpart
分区名称? []? part2
文件系统类型? [ext2]? ext4
起始点? 5G
结束点?
结束点? 10G
(parted) mkpart
分区名称? []? part3
文件系统类型? [ext2]? ext4
起始点? 10G
结束点? -1
(parted) p
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdc: 32.2GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name 标志
1 1000MB 5000MB 3999MB part1
2 5000MB 10.0GB 5001MB part2
3 10.0GB 32.2GB 22.2GB part3
1 1000MB 5000MB 3999MB part1
2 5000MB 10.0GB 5001MB part2
3 10.0GB 32.2GB 22.2GB part3
(parted) quit
信息: You may need to update /etc/fstab.
信息: You may need to update /etc/fstab.
[root@localhost ~]# ls -l /dev/sdc*
brw-rw---- 1 root disk 8, 32 8月 2 09:00 /dev/sdc
brw-rw---- 1 root disk 8, 33 8月 2 09:00 /dev/sdc1
brw-rw---- 1 root disk 8, 34 8月 2 09:00 /dev/sdc2
brw-rw---- 1 root disk 8, 35 8月 2 09:00 /dev/sdc3
[root@localhost ~]# mkfs.ext4 /dev/sdc1
mke2fs 1.42.9 (28-Dec-2013)
文件系统标签=
OS type: Linux
块大小=4096 (log=2)
分块大小=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
244320 inodes, 976384 blocks
48819 blocks (5.00%) reserved for the super user
第一个数据块=0
Maximum filesystem blocks=1000341504
30 block groups
32768 blocks per group, 32768 fragments per group
8144 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736
brw-rw---- 1 root disk 8, 32 8月 2 09:00 /dev/sdc
brw-rw---- 1 root disk 8, 33 8月 2 09:00 /dev/sdc1
brw-rw---- 1 root disk 8, 34 8月 2 09:00 /dev/sdc2
brw-rw---- 1 root disk 8, 35 8月 2 09:00 /dev/sdc3
[root@localhost ~]# mkfs.ext4 /dev/sdc1
mke2fs 1.42.9 (28-Dec-2013)
文件系统标签=
OS type: Linux
块大小=4096 (log=2)
分块大小=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
244320 inodes, 976384 blocks
48819 blocks (5.00%) reserved for the super user
第一个数据块=0
Maximum filesystem blocks=1000341504
30 block groups
32768 blocks per group, 32768 fragments per group
8144 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736
Allocating group tables: 完成
正在写入inode表: 完成
Creating journal (16384 blocks): 完成
Writing superblocks and filesystem accounting information: 完成
正在写入inode表: 完成
Creating journal (16384 blocks): 完成
Writing superblocks and filesystem accounting information: 完成
[root@localhost ~]# mkdir /sdc1
[root@localhost ~]# mount /dev/sdc1 /sdc1/
[root@localhost ~]# cd /sdc1/
[root@localhost sdc1]# echo ceshiwenjian > test.txt
[root@localhost sdc1]# cd
[root@localhost ~]# umount /sdc1/
[root@localhost ~]# parted /dev/sdc
GNU Parted 3.1
使用 /dev/sdc
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) p
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdc: 32.2GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
[root@localhost ~]# mount /dev/sdc1 /sdc1/
[root@localhost ~]# cd /sdc1/
[root@localhost sdc1]# echo ceshiwenjian > test.txt
[root@localhost sdc1]# cd
[root@localhost ~]# umount /sdc1/
[root@localhost ~]# parted /dev/sdc
GNU Parted 3.1
使用 /dev/sdc
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) p
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdc: 32.2GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name 标志
1 1000MB 5000MB 3999MB ext4 part1
2 5000MB 10.0GB 5001MB part2
3 10.0GB 32.2GB 22.2GB part3
1 1000MB 5000MB 3999MB ext4 part1
2 5000MB 10.0GB 5001MB part2
3 10.0GB 32.2GB 22.2GB part3
(parted) rm 1
(parted) p
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdc: 32.2GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
(parted) p
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdc: 32.2GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name 标志
2 5000MB 10.0GB 5001MB part2
3 10.0GB 32.2GB 22.2GB part3
2 5000MB 10.0GB 5001MB part2
3 10.0GB 32.2GB 22.2GB part3
(parted) rescue
起始点? 1
结束点? 5G
(parted) p
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdc: 32.2GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
起始点? 1
结束点? 5G
(parted) p
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdc: 32.2GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name 标志
2 5000MB 10.0GB 5001MB part2
3 10.0GB 32.2GB 22.2GB part3
2 5000MB 10.0GB 5001MB part2
3 10.0GB 32.2GB 22.2GB part3
(parted) rescue
起始点? 1
结束点? 5G
(parted) p
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdc: 32.2GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
起始点? 1
结束点? 5G
(parted) p
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdc: 32.2GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name 标志
2 5000MB 10.0GB 5001MB part2
3 10.0GB 32.2GB 22.2GB part3
2 5000MB 10.0GB 5001MB part2
3 10.0GB 32.2GB 22.2GB part3
(parted) rescue
起始点? 1G
结束点? 5G
正在搜索文件系统... 47% (剩余时间 00:06)信息: A ext4 primary partition was found at 1000MB -> 5000MB. Do you want to add it to the partition
table?
是/Yes/否/No/放弃/Cancel? y
(parted) p
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdc: 32.2GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
起始点? 1G
结束点? 5G
正在搜索文件系统... 47% (剩余时间 00:06)信息: A ext4 primary partition was found at 1000MB -> 5000MB. Do you want to add it to the partition
table?
是/Yes/否/No/放弃/Cancel? y
(parted) p
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdc: 32.2GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name 标志
1 1000MB 5000MB 3999MB ext4
2 5000MB 10.0GB 5001MB part2
3 10.0GB 32.2GB 22.2GB part3
1 1000MB 5000MB 3999MB ext4
2 5000MB 10.0GB 5001MB part2
3 10.0GB 32.2GB 22.2GB part3
(parted) q
信息: You may need to update /etc/fstab.
信息: You may need to update /etc/fstab.
[root@localhost ~]# mount /dev/sdc1 /sdc1/
[root@localhost ~]# cat /sdc1/test.txt
ceshiwenjian
[root@localhost ~]# cat /sdc1/test.txt
ceshiwenjian
18、尝试利用shell脚本配置yum仓库
19、尝试利用shell脚本配置httpd服务
20、尝试利用shell脚本将2~12题实现
注意:18 19 20 作为扩展,大家可以选作