linux学习方法五


相信不少想学习linux的新手们正愁不知道看什么linux学习教程好,下面小编给大家收集和整理了几点比较重要的教程,供大家学习,如需想学习更多的话,可到wdlinux学堂寻找更多教程。
Linux下挂载NTFS分区和挂载分区的方法
如果你的磁盘格式为NTFS就按照以下步骤如果不是就直接跳下一步
首先去下载个 NTFS-3G
下载地址:http://www.tuxera.com/community/ntfs-3g-download/
然后把下载好的压缩包上传到root文件夹内

列如:文件名为:ntfs-3g_ntfsprogs-2013.1.13.tgz


解压:tar zxvf ntfs-3g_ntfsprogs-2013.1.13.tgz
进入解压文件夹:cd ntfs-3g_ntfsprogs-2013.1.13
运行:
./configure
make
make install
到这里已经安装完成

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
查看分区信息:fdisk -l

如:
[root@PC ntfs-3g_ntfsprogs-2013.1.13]# fdisk -l
Disk /dev/vda: 21.5 GB, 21474836480 bytes
16 heads, 63 sectors/track, 41610 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000acae9

   Device Boot      Start         End      Blocks   Id  System
/dev/vda1   *           3         409      204800   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/vda2             409        8731     4194304   82  Linux swap / Solaris
Partition 2 does not end on cylinder boundary.
/dev/vda3            8731       41611    16571392   83  Linux
Partition 3 does not end on cylinder boundary.

Disk /dev/vdb: 64.4 GB, 64424509440 bytes
255 heads, 63 sectors/track, 7832 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: 0x5f72ecd9

   Device Boot      Start         End      Blocks   Id  System
/dev/vdb1               1        7832    62910508+  42  SFS     (我需要挂载的ntfs格式分区)

然后到/etc/fstab
打开fstab在添加一段自动挂载的代码
/dev/vdb1 /www ntfs-3g defaults 0 0

如果你的不是 ntfs格式呢就加你磁盘格式就好了
如:
/dev/vdb1 /www ext3  defaults 0 0

解释:
/dev/vdb1 为你的分区名称 在上步可以查看
/www 为需要挂载到文件夹


linux系统硬盘分区工具之fdisk
fdisk是linux下的一个硬盘分区工具硬盘分区原理一样,但工具格式等等都不一样,一个是在装系统时的分区,一个是装好系统后的分区
装系统时的分区,装好系统后一般是没法修改也不好调整的,在装系统时未分区的硬盘空间,装好系统后是可以操作或分区加载的

这里主要是说这种情况,一个是对未分区的空闲硬盘的操作,又或是对新加的硬盘操作
这里就要用到fdisk了,不过这个只能在2T以内的硬盘操作,大于2T的,就没法用了,得用到另一个parted的工具

还有一点,Linux对于硬盘的理解是以
/dev/hd|sd(a|b|xxx)这样方式的
hd主要是对于IDE的硬盘,这个已经很少见了
大部分都是sd开头的,包括stata,sas,scsi等接口的硬盘,比如
hda是第一块硬盘
hdb是第二块硬盘
sda是第一块硬盘
sdb是第二块硬盘
这里的顺序,还和一个因素有关,就是接口顺序或是跳线,大家应该知道,硬盘接口里是有一个跳线什么的,也就是一个主硬盘等

下面介绍fdisk的用法
fdisk -l是列表所有的硬盘,如下
[root@hnwt ~]# fdisk -l

Disk /dev/sda: 320.0 GB, 320071851520 bytes
255 heads, 63 sectors/track, 38913 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      104391   83  Linux
/dev/sda2              14       38913   312464250   8e  Linux LVM


fdisk /dev/sda表示操作硬盘,运行这个后会进入fdisk的交互状态,如下
[root@hnwt ~]# fdisk /dev/sda

The number of cylinders for this disk is set to 38913.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
   (e.g., DOS FDISK, OS/2 FDISK)

Command (m for help):

这里提示你,按m会提示一个帮助,如

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 列出所支持的所有分区类型
   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):

上面这里就列出了所有的参数
根据上面的提示,可以继续操作,如下简单说明
新加分区
1 按n新加
2 选择主分区/扩展分区
3 起始值,默认回车就可以
4 分区大小值
完成

删除分区
1 按d
2 选择相应的分区号,回车即可

改变分区类型
1 按t
2 选择分区
3 选择分区类型(按l可列表所有分区及ID)
linux下主要是一个交换分区里需要在此操作

一般的操作,有如上的三个
在所有操作完时,也确保正确时,可以按w保存并退出
如果有操作有误,按q直接退出就可以

上面的操作,请勿在线上环境/生产环境测试,否则后果自负
对于测试机或虚拟机,可以多操作几次,熟能生巧
 
 
linux系统重起/关机命令整理
重启命令:
1、reboot
2、shutdown -r now 立刻重启(root用户使用)
3、shutdown -r 10 过10分钟自动重启(root用户使用)
4、shutdown -r 20:35 在时间为20:35时候重启(root用户使用)
如果是通过shutdown命令设置重启的话,可以用shutdown -c命令取消重启


关机命令:
1、halt   立刻关机
2、poweroff 立刻关机
3、shutdown -h now 立刻关机(root用户使用)
4、shutdown -h 10 10分钟后自动关机
如果是通过shutdown命令设置关机的话,可以用shutdown -c命令取消重启
 
本文教程摘自 wdlinux论坛http://www.wdlinux.cn/bbs/,欢迎转载~

相关内容

    暂无相关文章