|
把一个磁盘/dev/sda挂载到某个目录下
- mkdir /mnt/long //创建一个空的挂载节点
- mount -t ext4 /dev/sda /mnt/long
复制代码 查看磁盘分区情况 fdisk -l
查看磁盘挂载情况df
对磁盘/dev/sdb分区
- [root@localhost ~]# fdisk /dev/sdc #进入磁盘
- Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
- Building a new DOS disklabel with disk identifier 0x45a3cadb.
- Changes will remain in memory only, until you decide to write them.
- After that, of course, the previous content won't be recoverable.
- Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
- 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
- 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 #各分区类型所对应的ID
- 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)
复制代码- Command (m for help): p //打印分区信息,可以看到当前并没有分区
- Disk /dev/sdc: 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: 0x45a3cadb
- Device Boot Start End Blocks Id System
- Command (m for help): n **//创建一个新的分区**
- Command action
- e extended//输入e为创建扩展分区
- p primary partition (1-4) //输入p为创建逻辑分区
- p
- Partition number (1-4): 1**//划分逻辑分区**
- First cylinder (1-2610, default 1): **//我这里直接回车,是不想把该磁盘分成多个分**区,把整个磁盘作为1个分区
- Using default value 1
- Last cylinder, +cylinders or +size{K,M,G} (1-2610, default 2610):
- Using default value 2610
- Command (m for help): p //再次查看可以看到该磁盘已经有1个分区了
- Disk /dev/sdc: 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: 0x45a3cadb
- Device Boot Start End Blocks Id System
- /dev/sdc1 1 2610 20964793+ 83 Linux
- Command (m for help): w //保存分区
- The partition table has been altered!
- Calling ioctl() to re-read partition table.
- Syncing disks.
复制代码 格式化磁盘
- mkfs.ext3 /dev/sdc1
- 或者mkfs.xfs
复制代码 修个配置文件开机自动挂载 vim /etc/fstab
- vim /etc/fstab
- /dev/sdc1(磁盘分区) /disk/disktwo(挂载目录) ext3(文件格式)defaults 0 0
复制代码
|
|