Wednesday, April 27, 2011

[Linux] filesystem的几个命令

查看filesystem type

$ df -T
Filesystem    Type   1K-blocks      Used Available Use% Mounted on
10.103.0.1:/nfsroot
               nfs   230583296 137044992  81824768  63% /
none      devtmpfs      497684       220    497464   1% /dev
none         tmpfs      502108         0    502108   0% /dev/shm
tmpfs        tmpfs      502108         0    502108   0% /tmp
none         tmpfs      502108        48    502060   1% /var/run
none         tmpfs      502108         0    502108   0% /var/lock
none         tmpfs      502108         0    502108   0% /lib/init/rw
/dev/sda1     ext4   115377640    192116 109324612   1% /localfs

查看硬盘

sudo fdisk -l /dev/sda
Disk /dev/sda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders, total 976773168 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: 0x0000c821

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048      499711      248832   83  Linux
/dev/sda2          501758   976771071   488134657    5  Extended
/dev/sda5          501760   976771071   488134656   8e  Linux LVM

格式化硬盘

首先使用fdisk在硬盘上建立partition
$ sudo fdisk /dev/sda
然后格式化
$ sudo mkfs.ext4 /dev/sda1
mke2fs 1.41.11 (14-Mar-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
4890624 inodes, 19537040 blocks
976852 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
597 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

Warning: could not read block 0: Attempt to read block from filesystem resulted in short read
Writing inode tables: 151/597
mount硬盘

$ sudo mount -t ext4 /dev/sda1 /my/mountpoint
$ sudo chown binfan:root /my/mountpoint
Ref
http://www.tldp.org/HOWTO/Partition/fdisk_partitioning.html

No comments: