suse11下创建分区,并设置开机自动挂载

步骤(1)查看目前磁盘的状态和使用情况:

linux:~ # fdisk –l

Disk /dev/sda: 2000.4 GB, 2000398934016bytes

255 heads, 63 sectors/track, 243201cylinders

Units = cylinders of 16065 * 512 = 8225280bytes

Disk identifier: 0x0001fa9a

  Device Boot      Start         End     Blocks   Id  System

/dev/sda1  *           1       26108  209712478+  83  Linux

/dev/sda2           26109       30285   33551752+  82  Linux swap / Solaris

linux:~ # df -h

Filesystem            Size  Used Avail Use% Mounted on

/dev/sda1             197G  18G  170G  10% /

devtmpfs              118G  120K 118G   1% /dev

 tmpfs                  64G  176K  64G   1% /dev/shm

 

步骤(2)下面在/dev/sda上分一个100G分区出来:

linux:~ # fdisk /dev/sda

The number of cylinders for this disk isset to 243201.

There is nothing wrong with that, but thisis larger than 1024,

and could in certain setups cause problemswith:

1) software that runs at boot time (e.g.,old versions of LILO)

2) booting and partitioning software fromother OSs

   (e.g., DOS FDISK, OS/2 FDISK)

Command (m for help): n         ——创建新分区

Command action

  e   extended

  p   primary partition (1-4)

p     ——创建分区类型,e:扩展分区,p:主分区

Partition number (1-4): 3      ——分区编号

First cylinder (30286-243201, default30286):    ——‘回车’默认

Using default value 30286

Last cylinder, +cylinders or +size{K,M,G}(30286-243201, default 243201): +100GB    ——指定分区大小(点‘回车’后就创建成功了)

Command (m for help): p     ——打印分区表,可查看到新建的分区

Disk /dev/sda: 2000.4 GB, 2000398934016bytes

255 heads, 63 sectors/track, 243201cylinders

Units = cylinders of 16065 * 512 = 8225280bytes

Disk identifier: 0x0001fa9a

  Device Boot      Start         End     Blocks   Id  System

/dev/sda1  *           1       26108  209712478+  83  Linux

/dev/sda2           26109       30285   33551752+  82  Linux swap / Solaris

/dev/sda3           30286       42444   97667167+  83  Linux

Command (m for help): w        ——写分区表并退出

 

linux:~ # fdisk -l

Disk /dev/sda: 2000.4 GB, 2000398934016bytes

255 heads, 63 sectors/track, 243201cylinders

Units = cylinders of 16065 * 512 = 8225280bytes

Disk identifier: 0x0001fa9a

  Device Boot      Start         End     Blocks   Id  System

/dev/sda1  *           1       26108  209712478+  83  Linux

/dev/sda2           26109       30285   33551752+  82  Linux swap / Solaris

/dev/sda3           30286       42444   97667167+  83  Linux         ——创建成功

补充:如果已经创建了四个主分区,那么再进行分区就会有如下提示:

Command(m for help): n

Youmust delete some partition and add an extended partition first

这样必须先删除一个主分区,然后创建一个扩展分区,这是一个需要注意的地方,在分区规划时,如果要创建的主分区大于四个,那么在创建了三个主分区后,就需要创建一个扩展分区才能满足规划需求。

 

步骤(3)格式化分区并挂载

按照步骤(2)创建好就进行如下格式化:

linux:~ # mkfs.ext3 /dev/sda3

mke2fs 1.41.9 (22-Aug-2009)

Could not stat /dev/sda3 --- No such fileor directory

The device apparently does not exist; didyou specify it correctly?

报错了?!这个问题有两个解决办法:重启 or不重启——使用partprobe命令,当然还是partprobe命令好使哈,执行如下命令后成功将分区格式化为ext3文件系统

linux:~ # partprobe

linux:~ # mkfs.ext3 /dev/sda3

Filesystem label=

OS type: Linux

Block size=4096 (log=2)

Fragment size=4096 (log=2)

6111232 inodes, 24416791 blocks

1220839 blocks (5.00%) reserved for thesuper user

First data block=0

Maximum filesystem blocks=4294967296

746 block groups

32768 blocks per group, 32768 fragments pergroup

8192 inodes per group

Superblock backups stored on blocks:

       32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,

       4096000, 7962624, 11239424, 20480000, 23887872

Writing inode tables: done                           

Creating journal (32768 blocks): done

Writing superblocks and filesystemaccounting information: done

This filesystem will be automaticallychecked every 29 mounts or

180 days, whichever comes first.  Use tune2fs -c or -i to override.

 

一切顺利,下面就可以挂载了:

linux:/ # mkdir mynewpt

linux:/ # mount /dev/sda3/mynewpt

linux:/ # df -h

Filesystem            Size  Used Avail Use% Mounted on

/dev/sda1             197G  18G  170G  10% /

devtmpfs              118G 124K  118G   1% /dev

tmpfs                  64G 176K   64G   1% /dev/shm

/dev/sda3              92G  188M  87G   1% /mynewpt      ——成功,分区完成

 

步骤(4)很简单吧,呵呵,不要着急,还有最后一个需要完善的地方。按照上面操作后,盘是分出来了,但是要是重启了系统后,你会发现/dev/sda3没有自动挂载上,这样很麻烦,每次需要自己手动执行mount命令来挂载。需要启动自动挂载的话,只需要修改配置文件:

linux:/ # vi /etc/fstab  ——添加如下一行即可:

/dev/sda3            /mynewpt                ext3       defaults              0 0

你可能感兴趣的:(linux)