Chinaunix首页 | 论坛 | 博客
  • 博客访问: 326676
  • 博文数量: 103
  • 博客积分: 3886
  • 博客等级: 中校
  • 技术积分: 1005
  • 用 户 组: 普通用户
  • 注册时间: 2010-04-28 15:00
文章分类

全部博文(103)

文章存档

2011年(30)

2010年(73)

分类: LINUX

2011-04-25 13:26:26

touch [-acfm]
[-r reference-file] [--file=reference-file]
[-t MMDDhhmm[[CC]YY][.ss]]
[-d time] [--date=time] [--time={atime,access,use,mtime,modify}]
[--no-create] [--help] [--version]
file1 [file2 ...]
说明:
touch 指令改变档案的时间记录。 ls -l 可以显示档案的时间记录。
参数:
a 改变档案的读取时间记录。
m 改变档案的修改时间记录。
c 假如目的档案不存在,不会建立新的档案。与 --no-create 的效果一样。
f 不使用,是为了与其他 unix 系统的相容性而保留。
r 使用参考档的时间记录,与 --file 的效果一样。
d 设定时间与日期,可以使用各种不同的格式。
t 设定档案的时间记录,格式与 date 指令相同。
--no-create 不会建立新档案。
--help 列出指令格式。
--version 列出版本讯息。

范例:
最简单的使用方式,将档案的时候记录改为现在的时间。若档案不存在,系统会建立一个新的档案。
touch file
touch file1 file2

将 file 的时间记录改为 5 月 6 日 18 点 3 分,公元两千年。
时间的格式可以参考 date 指令,至少需输入 MMDDHHmm ,就是月日时与分。
touch -c -t 05061803 file
touch -c -t 050618032000 file
将 file 的时间记录改变成与 referencefile 一样。
touch -r referencefile file
将 file 的时间记录改成 5 月 6 日 18 点 3 分,公元两千年。
时间可以使用 am, pm 或是 24 小时的格式,日期可以使用其他格式如 6 May 2000。
====================================================================================
touch -d 和 date -s 的用法相同。
如果没有指定日期,默认为系统日期
touch -d 18:03 file
touch -d "18:03" file
touch -d "6:03pm" file

如果没有指定时间,默认为 00:00:00
touch -d 20000506 file
touch -d "05/06/2000" file
touch -d "20000506" file
touch -d "6:03pm 05/06/2000" file
touch -d "20000506 18:03" file
touch -d "20000506 18:03:00" file
 
 
[root@abintel ~]# parted --help
用法:parted [选项]... [设备 [命令 [参数]...]...]
将带有“参数”的命令应用于“设备”。如果没有给出“命令”,则以交互模式运行。

选项:
-h, --help                    显示此求助信息
-i, --interactive             在必要时,提示用户
-s, --script                  从不提示用户
-v, --version                 显示版本

命令:
检查 MINOR                   对文件系统进行一个简单的检查
cp [FROM-DEVICE] FROM-MINOR TO-MINOR      将文件系统复制到另一个分区
help [COMMAND]                打印通用求助信息,或关于 COMMAND 的信息
mklabel 标签类型              创建新的磁盘标签 (分区表)
mkfs MINOR 文件系统类型       在 MINOR 创建类型为“文件系统类型”的文件系统
mkpart 分区类型 [文件系统类型] 起始点 终止点      创建一个分区
mkpartfs 分区类型 文件系统类型 起始点 终止点 创建一个带有文件系统的分区
move MINOR 起始点 终止点      移动编号为 MINOR 的分区
name MINOR 名称               将编号为 MINOR 的分区命名为“名称”
print [MINOR]                 打印分区表,或者分区
quit                          退出程序
rescue 起始点 终止点          挽救临近“起始点”、“终止点”的遗失的分区
resize MINOR 起始点 终止点    改变位于编号为 MINOR 的分区中文件系统的大小
rm MINOR                      删除编号为 MINOR 的分区
select 设备                 选择要编辑的设备
set MINOR 标志 状态           改变编号为 MINOR 的分区的标志


大于1T的磁盘进行分区
遇到一个问题,大磁盘的超过1T的时候fdisk无法分区,到网上找了半天才知道是用parted可以作,有网络真好啊.:D
下面一块有3T RAID的硬盘的分区情况
#parted /dev/sdc
GNU Parted 1.6.19
Copyright (C) 1998 - 2004 Free Software Foundation, Inc.
This program is free software, covered by the GNU General Public License.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
Using /dev/sdc
(parted) m
check MINOR do a simple check on the filesystem
cp [FROM-DEVICE] FROM-MINOR TO-MINOR copy filesystem to another partition
help [COMMAND] prints general help, or help on COMMAND
mklabel LABEL-TYPE create a new disklabel (partition table)
mkfs MINOR FS-TYPE make a filesystem FS-TYPE on partititon MINOR
mkpart PART-TYPE [FS-TYPE] START END make a partition
mkpartfs PART-TYPE FS-TYPE START END make a partition with a filesystem
move MINOR START END move partition MINOR
name MINOR NAME name partition MINOR NAME
print [MINOR] display the partition table, or a partition
quit exit program
rescue START END rescue a lost partition near START and END
resize MINOR START END resize filesystem on partition MINOR
rm MINOR delete partition MINOR
select DEVICE choose the device to edit
set MINOR FLAG STATE change a flag on partition MINOR
(parted) p
Disk geometry for /dev/sdc: 0.000-2860032.000 megabytes
Disk label type: gpt
Minor Start End Filesystem Name Flags
1 0.017 1000.000 ext3
2 1000.000 2000.000 ext3
3 2000.000 3000.000 ext3
(parted) rm 3
(parted) rm 2
(parted) rm 1
(parted) mkpartfs primary ext3 0 1000000
No Implementation: Support for creating ext3 file systems is not implemented yet.
(parted) mkpart primary 0 1000000
(parted) mkpart primary 1000000 2000000
(parted) mkpart primary 2000000 3000000
Error: Can't have a partition outside the disk!
(parted) mkpart primary 2000000 2800000
(parted) q
Information: Don't forget to update /etc/fstab, if necessary.
#mkfs.ext3 /dev/sdc1
mke2fs 1.35 (28-Feb-2004)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
128008192 inodes, 255999995 blocks
12799999 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=260046848
7813 block groups
32768 blocks per group, 32768 fragments per group
16384 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 (8192 blocks): done
Writing superblocks and filesystem accounting information:
done
This filesystem will be automatically checked every 20 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.


linux支持2T以上大硬盘分区的安装手记


背景:构建图书馆光盘管理系统FTP,6块硬盘,每个1TB,用一块硬盘做raid0,安装系统,剩余5块做raid5。由于ext3文件系统不支持大于 2TB的分区,所以考虑使用GPT首先以root身份登录系统,查看硬盘信息:fdisk -l
复制内容到剪贴板
代码:
[root@libftp ~]# fdisk -l

Disk /dev/cciss/c0d0: 1000.1 GB, 1000171331584 bytes
255 heads, 63 sectors/track, 121597 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot      Start         End      Blocks   Id System
/dev/cciss/c0d0p1   *           1          33      265041   83 Linux
/dev/cciss/c0d0p2              34      116105   932348340   83 Linux
/dev/cciss/c0d0p3          116106      118655    20482875   83 Linux
/dev/cciss/c0d0p4          118656      121597    23631615    5 Extended
/dev/cciss/c0d0p5          118656      120567    15358108+ 83 Linux
/dev/cciss/c0d0p6          120568      121587     8193118+ 82 Linux swap / Solaris

WARNING: GPT (GUID Partition Table) detected on '/dev/cciss/c0d1'! The util fdisk doesn't support GPT. Use GNU Parted.


Disk /dev/cciss/c0d1: 4000.6 GB, 4000684662784 bytes
255 heads, 63 sectors/track, 486388 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot      Start         End      Blocks   Id System
/dev/cciss/c0d1p1               1      267350 2147483647+ ee EFI GPT
使用parted命令:
复制内容到剪贴板
代码:
[root@libftp ~]# parted /dev/cciss/c0d1
GNU Parted 1.8.1
Using /dev/cciss/c0d1
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) mklabel gpt                                                      
Warning: The existing disk label on /dev/cciss/c0d1 will be destroyed and all data on this disk will be lost. Do you want to
continue?
Yes/No? y                                                                                                          
New disk label type? [gpt]? gpt
下一步:由MBR转为GPT磁盘
复制内容到剪贴板
代码:
(parted) mkpart primary 0 4000GB
print:
复制内容到剪贴板
代码:
(parted) print                                                            

Model: Compaq Smart Array (cpqarray)
Disk /dev/cciss/c0d1: 4001GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt

Number Start   End     Size    File system Name     Flags
1      17.4kB 4001GB 4001GB               primary       

(parted) quit                                                             
Information: Don't forget to update /etc/fstab, if necessary.             
下一步:格式化
复制内容到剪贴板
代码:
[root@libftp ~]# mkfs.ext3 -F /dev/cciss/c0d1
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
488374272 inodes, 976729654 blocks
48836482 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=0
29808 block groups
32768 blocks per group, 32768 fragments per group
16384 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, 512000000, 550731776, 644972544

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

This filesystem will be automatically checked every 22 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
此时注意事项:mkfs.ext3 -F   后面要跟上 -F下一步 :挂载
复制内容到剪贴板
代码:
[root@libftp ~]# mkdir -p /mnt/cciss/c0d1
[root@libftp ~]# mount /dev/cciss/c0d1 /mnt/cciss/c0d1
查看:
复制内容到剪贴板
代码:
[root@libftp ~]# df -h
Filesystem            Size Used Avail Use% Mounted on
/dev/cciss/c0d0p5      15G 1.8G   12G 13% /
/dev/cciss/c0d0p3      19G 173M   18G   1% /usr/local
/dev/cciss/c0d0p2     862G 200M 817G   1% /else
/dev/cciss/c0d0p1     251M   21M 218M   9% /boot
tmpfs                 2.0G     0 2.0G   0% /dev/shm
/dev/cciss/c0d1       3.6T 197M 3.4T   1% /mnt/cciss/c0d1
开机自动挂载这块硬盘:vi /etc/rc.local加上:
复制内容到剪贴板
代码:
mount /dev/cciss/c0d1 /mnt/cciss/c0d1
搞定.
因为fdisk是不支持GPT磁盘,所以不要使用fdisk -l来查看X磁盘刚才分好的区,看不到的
 
 
 

column命令用于格式化列信息。

column命令的使用格式如下:

column [-tx] [-c columns] [-s sep] [file ...]

常用的选项

-c      Output is formatted for a display columns wide.

-s      Specify a set of characters to be used to delimit columns for the -t option.

-t      Determine the number of columns the input contains and create a table.  Columns are delimited with whitespace, by
        default, or with the characters supplied using the -s option.  Useful for pretty-printing displays.

-x      Fill columns before filling rows.

eg:

#mount | column -t |sort  

//192.168.3.33/test               on  /mnt                      type  cifs         (rw,mand)
/data/redhat/images/diskboot.img  on  /data/redhat/images/test  type  vfat         (rw,loop=/dev/loop0)
devpts                            on  /dev/pts                  type  devpts       (rw,gid=5,mode=620)
/dev/sda1                         on  /boot                     type  ext3         (rw)
/dev/sda2                         on  /opt                      type  ext3         (rw)
/dev/sda3                         on  /var                      type  ext3         (rw)
/dev/sda5                         on  /usr                      type  ext3         (rw)
/dev/sda6                         on  /home                     type  ext3         (rw)
/dev/sda7                         on  /                         type  ext3         (rw)
/dev/sda9                         on  /data                     type  ext3         (rw)
/home/pupai/test                  on  /test                     type  none         (rw,bind)
none                              on  /proc/sys/fs/binfmt_misc  type  binfmt_misc  (rw)
proc                              on  /proc                     type  proc         (rw)
sysfs                             on  /sys                      type  sysfs        (rw)
tmpfs                             on  /dev/shm                  type  tmpfs        (rw)

阅读(1259) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~