标签:
首先介绍一下fdisk命令,这是一个分区工具。用法如下:
[root@localhost beinan]# fdisk /dev/sda 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 注:这是删除一个分区的动作; l list known partition types 注:l是列出分区类型,以供我们设置相应分区的类型; m print this menu 注:m 是列出帮助信息; n add a new partition 注:添加一个分区; o create a new empty DOS partition table p print the partition table 注:p列出分区表; q quit without saving changes 注:不保存退出; s create a new empty Sun disklabel t change a partition‘s system id 注:t 改变分区类型; 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): n #新建命令 Partition type: p primary (0 primary, 0 extended, 4 free) e extended Select (default p): p #P表示主分区,e表示扩展分区,这里我们新建一个主分区 Partition number (1-4, default 1): #分区号默认即可 Using default value 1 First sector (2048-16777215, default 2048): Using default value 2048 Last sector, +sectors or +size{K,M,G} (2048-16777215, default 16777215): +6G #在开始字节的基础上加6G Command (m for help): n #新建第二个分区 Partition type: p primary (1 primary, 0 extended, 3 free) e extended Select (default p): p #这里选择的依然是主分区(主分区+扩展分区 <= 4) Partition number (1-4, default 2): Using default value 2 First sector (12584960-16777215, default 12584960): Using default value 12584960 Last sector, +sectors or +size{K,M,G} (12584960-16777215, default 16777215): Using default value 16777215 Command (m for help): w #保存命令!最后一定记得保存,否则前面的分区功亏一篑。 The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks.
Command (m for help): p #查看一下刚才的分区 Disk /dev/sdb: 8589 MB, 8589934592 bytes 255 heads, 63 sectors/track, 1044 cylinders, total 16777216 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x2aee38be Device Boot Start End Blocks Id System /dev/sdb1 2048 12584959 6291456 83 Linux /dev/sdb2 12584960 16777215 2096128 83 Linux
Command (m for help): q #最后退出
格式化用到了mkfs命令:
root@bogon:/dev# mkfs.ext4 /dev/adb1 #命令的格式是mkfs.ext4 分区设备名 root@bogon:/dev# mkswap /dev/sdb2 #格式化交换分区
挂载分区
mkdir /mnt/lfs mount -v -t ext4 /dev/sdb1 /mnt/lfs
export LFS=/mnt/lfs
切换环境是记得检查此变量了之是否改变
标签:
原文地址:http://my.oschina.net/icngor/blog/525808