Linux系统庞大的磁盘分区命令

本文发布时间: 2019-Mar-22
如果要在系统里面新增一个硬盘,需要做如下一些事情:1、对磁盘分区,以建立可用的分区。2、对分区进行格式化,以建立可用的文件系统。3、若想要仔细一点,可对刚刚建立好的文件系统进行检验。4、在Linux系统上,需要建立载入点(即目录),并将它载入。命令fdisk [-l] 设备名称:其中参数 -l :输出后面接的设备所有的分区内容。若仅有fdisk -l 时,将会把整个系统内能够搜索到的设备分区均列出来。范例一:查看第一个硬盘内的相关信息:fdisk /dev/sdaroot@dum-ThinkPad-E425:/home/dum# fdisk /dev/sdaThe device presents a logical sector size that is smaller thanthe physical sector size. Aligning to a physical sector (or optimalI/O) size boundary is recommended, or performance may be impacted.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): m (输入m后就会看到下面这写命令说明)Command action a toggle a bootable flag b edit bsd disklabel c toggle the dos compatibility flag d delete a partition l list known partition types m print this menu n add a new partition o create a new empty DOS partition table p print the partition table 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)这里注意一下,使用fdisk程序完全不需要背命令,因为按下m之后,立刻就会有一堆说明显示出来,在上面的命令中,比较重要的有:d删除一个分区,n新增一个分区,p列出当前的分区,q不存储离开,这很重要。w写入分区表后离开,这个比较危险,要注意。Command (m for help): p (这里可以输出当前磁盘的状态)Disk /dev/sda: 320.1 GB, 320072933376 bytes255 heads, 63 sectors/track, 38913 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesSector size (logical/physical): 512 bytes / 4096 bytesI/O size (minimum/optimal): 4096 bytes / 4096 bytesDisk identifier: 0x0009c985 Device Boot Start End Blocks Id System/dev/sda1 * 1 2432 19530752 83 Linux/dev/sda2 2432 2736 2444288 82 Linux swap / Solaris/dev/sda3 2736 38914 290594816 83 Linux由上面的信息可以知道硬盘是320G,Head/Sector/cylinders的数量为255/63/38913.可以看到boot,那个地方有表示启动信息的分区/dev/sda1.另外start与end则指每一个分区的开始与结束的柱面号,所以可知分区的最小单位为柱面。范例二:查看系统内的所有分区:fdisk -lfdisk最主要的工作就是修改“分区表”,并没有实际将硬盘划分,它会定义出某一个分区是n1到n2柱面之间。因此,如果硬盘分区错误,只要在格式化之前将分区表复原,就可以将硬盘原来的数据救回来。另外,只有root才可以执行fdisk.磁盘格式化:命令:mke2fs [-bicLj] 设备名称范例一:将建立的/dev/hdb5格式化为ext3,且名称为logical:mke2fs -j -L "logical" /dev/hdb5如果将块改为2048,inode改为4096呢?:mke2fs -j -L "logical" -b 2048 -i 4096 /dev/hdb5


(以上内容不代表本站观点。)
---------------------------------
本网站以及域名有仲裁协议。
本網站以及域名有仲裁協議。

2024-Mar-04 02:11pm
栏目列表