Apabila memasang centos pada pelayan, biasanya partition sistem Linux lalai kepada 3 partition, dengan maksimum 4 partition utama yang lain boleh dipasang mengikut keperluan anda sendiri.
/ Pembahagian akar, biasanya kira-kira 10-100G (bergantung kepada jumlah saiz cakera)
/petak operasi sistem but (100-500MB sudah memadai)
/tukar partition sementara memori maya (biasanya 2 kali ganda memori)
Jika ada baki cakera, simpan dan lekapkannya kemudian. Selepas memasang sistem, mula memformat partition yang tinggal dan memasangnya.
1. Mula-mula semak nama partition yang tidak ditetapkan Sesetengahnya adalah /dev/sda dan /dev/sdb ialah partition sistem dan sdb ialah partition data storan.
# fdisk -l Disk /dev/sda: 10.7 GB, 10737418240 bytes, 20971520 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 4096 bytes I/O size (minimum/optimal): 4096 bytes / 4096 bytes Disk label type: dos Disk identifier: 0x00043041 Device Boot Start End Blocks Id System /dev/sda1 * 2048 2099199 1048576 83 Linux /dev/sda2 2099200 20971519 9436160 8e Linux LVM Disk /dev/sdb: 10.7 GB, 10737418240 bytes, 20971520 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 4096 bytes I/O size (minimum/optimal): 4096 bytes / 4096 bytes Disk /dev/mapper/cl-root: 8585 MB, 8585740288 bytes, 16769024 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 4096 bytes I/O size (minimum/optimal): 4096 bytes / 4096 bytes Disk /dev/mapper/cl-swap: 1073 MB, 1073741824 bytes, 2097152 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 4096 bytes I/O size (minimum/optimal): 4096 bytes / 4096 bytes
2. Anda boleh melihat bahawa cakera data 10G ditandakan dengan warna merah
# fdisk -S 56 /dev/sdb Welcome to fdisk (util-linux 2.23.2). Changes will remain in memory only, until you decide to write them. Be careful before using the write command. Device does not contain a recognized partition table Building a new DOS disklabel with disk identifier 0x52d681d6. The device presents a logical sector size that is smaller than the physical sector size. Aligning to a physical sector (or optimal I/O) size boundary is recommended, or performance may be impacted. Command (m for help):【输入n回车,添加新分区,如果需要更多,请输入m回车看帮助】 Partition type: p primary (0 primary, 0 extended, 4 free) e extended Select (default p):【输入p回车,P的意思是主分区】 Partition number (1-4, default 1):【输入数字1回车,分区数量】 First sector (2048-20971519, default 2048):【默认回车】 Using default value 2048 Last sector, +sectors or +size{K,M,G} (2048-20971519, default 20971519):【默认回车】 Using default value 20971519 Partition 1 of type Linux and of size 10 GiB is set Command (m for help):【输入wq保存】 The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks.
Disk /dev/sda: 10.7 GB, 10737418240 bytes, 20971520 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 4096 bytes I/O size (minimum/optimal): 4096 bytes / 4096 bytes Disk label type: dos Disk identifier: 0x00043041 Device Boot Start End Blocks Id System /dev/sda1 * 2048 2099199 1048576 83 Linux /dev/sda2 2099200 20971519 9436160 8e Linux LVM Disk /dev/sdb: 10.7 GB, 10737418240 bytes, 20971520 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 4096 bytes I/O size (minimum/optimal): 4096 bytes / 4096 bytes Disk label type: dos Disk identifier: 0x52d681d6 Device Boot Start End Blocks Id System /dev/sdb1 2048 20971519 10484736 83 Linux Disk /dev/mapper/cl-root: 8585 MB, 8585740288 bytes, 16769024 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 4096 bytes I/O size (minimum/optimal): 4096 bytes / 4096 bytes Disk /dev/mapper/cl-swap: 1073 MB, 1073741824 bytes, 2097152 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 4096 bytes I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Nota: Terdapat beberapa format cakera biasa di bawah Jika anda ingin memformat format ext3, kodnya adalah seperti berikut;
# mkfs.ext3 /dev/sdb1 格式化ext4格式,代码如下; # mkfs.ext4 /dev/sdb1 我这里采用的是xfs磁盘格式;代码如下; # mkfs.xfs -f /dev/sdb1 meta-data=/dev/sdb1 isize=512 agcount=4, agsize=655296 blks = sectsz=4096 attr=2, projid32bit=1 = crc=1 finobt=0, sparse=0 data = bsize=4096 blocks=2621184, imaxpct=25 = sunit=0 swidth=0 blks naming =version 2 bsize=4096 ascii-ci=0 ftype=1 log =internal log bsize=4096 blocks=2560, version=2 = sectsz=4096 sunit=1 blks, lazy-count=1 realtime =none extsz=4096 blocks=0, rtextents=0
# echo ‘/dev/sdb1 /www xfs defaults 0 0’ >> /etc/fstab # mkdir /www //新建挂载目录 # mount -a //挂载磁盘 # df -h //查看挂载是否成功 Filesystem Size Used Avail Use% Mounted on /dev/mapper/cl-root 8.0G 3.1G 5.0G 39% / devtmpfs 906M 0 906M 0% /dev tmpfs 916M 0 916M 0% /dev/shm tmpfs 916M 8.3M 908M 1% /run tmpfs 916M 0 916M 0% /sys/fs/cgroup /dev/sda1 1014M 138M 877M 14% /boot tmpfs 184M 0 184M 0% /run/user/0 /dev/sdb1 10G 33M 10G 1% /www
6 Anda boleh melihat bahawa direktori www telah berjaya dipasang.
Bacaan lanjutan, adalah berguna untuk memasukkan m apabila fdisk -S 56 /dev/sdb, berikut adalah arahannya:
a、toggle a bootable flag //切换一个可启动的标志 b、 edit bsd disklabel //编辑bsd disklabel c、 toggle the dos compatibility flag //切换dos兼容性模式 d、 delete a partition //删除一个分区 g、 create a new empty GPT partition table //创建一个新的空GPT分区表 G 、create an IRIX (SGI) partition table //创建一个IRIX(SGI)分区表 l 、list known partition types //列出已知的分区类型 m、 print this menu //打印此菜单 n、 add a new partition //添加一个新的分区 o、 create a new empty DOS partition table //创建一个新的空DOS分区表 p、 print the partition table //打印分区表 q、 quit without saving changes //退出而不保存更改 s、 create a new empty Sun disklabel //创建一个新的空的Sun磁盘标签 t、 change a partition’s system id //更改分区的系统ID u、 change display/entry units //更改显示/输入单位 v、 verify the partition table //验证分区表 w、 write table to disk and exit //将表写入磁盘保存并退出 x、extra functionality (experts only) //高级功能(仅限专家)
Atas ialah kandungan terperinci Pemformatan partition sistem Linux dan cakera pelekap. Untuk maklumat lanjut, sila ikut artikel berkaitan lain di laman web China PHP!