Think before you speak, read before you think.

linux的分区格式化,挂载

by

in

在服务器使用过程中,某分区不够用,服务器只有一个硬盘,当时装系统之时,有一个sda3分区未使用。

现将其格式化为ext3格式,挂载到/data下面,并且开机要自动挂载。

这里先使用parted,它是一个调整分区的工具,不过现在使用它的显示功能,并不对硬盘做修改。p 代表print ,查看当前分区情况:

#parted

GNU Parted 2.1
Using /dev/sda
Welcome to GNU Parted! Type ‘help’ to view a list of commands.

(parted) p

Model: ATA ST31000528AS (scsi)
Disk /dev/sda: 1000GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number Start End Size Type File system Flags
1 1049kB 211MB 210MB primary ext3 boot
2 211MB 2358MB 2147MB primary linux-swap(v1)
3 2358MB 1000GB 998GB primary

(parted) quit

可以发现sda3没有显示file system,说明未格式化,现使用mkfs.ext3来把sda3格式化

mkfs.ext3 /dev/sda3

mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
60907520 inodes, 243614264 blocks
12180713 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
7435 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,
102400000, 214990848

Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 33 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.

现在重新查看分区情况,已经是ext3

3 2358MB 1000GB 998GB primary ext3

创建目录/data,作为sda3的挂载点

mkdir /data
mount -v /dev/sda3 /data/

为了之后开机挂载,在/etc/fstab写入如下一行

/dev/sda3               /data                   ext3    defaults        1 1

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *