Archive for March, 2015

Linux system to mount、Uninstall the new hard disk method

VMware virtual machine,Linux system to mount、Uninstall the new hard disk method
load:

1、Start vm,Select vm->Settings,Follow the wizard to add a SCSI disk。Into the Linux system。
2、 fdisk -l will see a new set,If you previously have a hard drive(sda1, sda3…),This should be added the new(/dev / sdb)。 (If you add a second hard drive is IDE hard disk,You should see hdb,If the SCSI hard disk,See is what should sdb)
[root@localhost ~]# fdisk -l

Disk / dev / sda: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev / sda1 * 1 13 104391 83 Linux
/dev / sda3 14 1044 8281507+ 83 Linux

Disk /dev/sdb: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdb doesn’t contain a valid partition table

3、Partition:
[root@localhost ~]# fdisk / dev / sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won’t be recoverable.

The number of cylinders for this disk is set to 1044.
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)
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

Command (m for help): m ## m press here ,Output will help;
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition ## which is to delete a partition action;
l list known partition types ##:l is to list the partition type,We set the type for the corresponding partition;
m print this menu
n add a new partition ## to add a partition;
o create a new empty DOS partition table
p print the partition table ## p listed in the partition table;
q quit without saving changes ##不保存退出;
s create a new empty Sun disklabel
t change a partition's system id ## t to change the partition type;
u change display/entry units
v verify the partition table
w write table to disk and exit ## of the partition table is written to disk and exit;
x extra functionality (experts only) ##Extended Application,Expert Features;

Command (m for help): n
Command action
e extended ## extended partition
p primary partition (1-4) ##Built selected p primary partition
p
Partition number (1-4): 1
First cylinder (1-17849, default 1): ##Note:This is the Start value partition;Here the best press enter,If you enter a non-default number,It will result in wasted space;
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-17849, default 17849): 8920
Using default value 500
##This is the definition of the size of the partition,+200M is the size of 200M ;Of course, you can also according to the size of the tip above the cylinder unit to count,Then specify the value End,In fdisk -l command can be seen in Units = cylinders of 16065 * 512 = 8225280 bytes,This unit is the size of the cylinder,I am here to choose the End value is 8920,Exactly half the total size,71G about

##Then come to build a primary partition
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (8921-17849, default 8921):8921
Using default value 8921
Last cylinder or +size or +sizeM or +sizeK (8921-17849, default 17849):17849
Using default value 17849
##Finally, save and exit,Remember,Be sure to save,Or will not take effect。
Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
##Use fdisk -l command to view disk status:
[root@localhost ~]# fdisk -l

Disk / dev / sda: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev / sda1 * 1 13 104391 83 Linux
/dev / sda3 14 1044 8281507+ 83 Linux

Disk /dev/sdb: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sdb1 1 8920 71649868+ 83 Linux
/dev/sdb2 8921 17849 71722192+ 83 Linux
##Disk / dev / sdb has been divided into two partitions,Each partition size is probably around 71G。

##Prior to mount the file system,You need to be / dev / sdb1 and / dev / sdb2 re-use mkfs -t ext3 formatted commands about,Otherwise the mount will complain。
4、Format the partition:Use mkfs.ext3 / dev / sdb command to format the disk Note:You can also use the mkfs -t ext3 / dev / sdb command
[root@localhost ~]# mkfs -t ext3 / dev / sdb1 ## refers to the disk formatted to ext3 file system
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
1048576 inodes, 2096474 blocks
104823 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2147483648
64 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

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

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

supplement:Mounting
Mounting File Systems,There are two methods:
First, through the mount to mount,Use mount mount system,Once the system is restarted will need to be remounted。
Second, through the / etc / fstab file to automatically mount the boot。
I put the / dev / sdb1 mount / test next
[root@localhost ~]# mkdir /test ## Firstly mounted directory test
(or[root@localhost ~]# cd /
[root@localhost ~]# mkdir test
)
[root@localhost ~]# df -h ## mounted in front of the partition
Filesystem Size Used Avail Use% Mounted on
/dev / mapper / VolGroup00-LogVol00
6.7G 5.8G 576M 92% /
/dev/sda1 99M 12M 82M 13% /boot
tmpfs 233M 0 233M 0% /dev/shm
[root@localhost ~]# mount /dev/sdb1 /test
[root@localhost ~]# Partition df -h ## mounted after
Filesystem Size Used Avail Use% Mounted on
/dev / mapper / VolGroup00-LogVol00
6.7G 5.8G 576M 92% /
/dev/sda1 99M 12M 82M 13% /boot
tmpfs 233M 0 233M 0% /dev/shm
/dev / sdb1 7.9G 147M 7.4G 2% /test
6、Via / etc / fstab file to automatically mount the boot(Otherwise, the system will not be saved after restart the computer before the mount operation):
[root@localhost ~]# vi / etc / fstab
/dev / VolGroup00 / LogVol00 / ext3 defaults 1 1
LABEL=/boot /boot ext3 defaults 1 2
devpts /dev/pts devpts gid=5,mode=620 0 0
tmpfs /dev/shm tmpfs defaults 0 0
proc /proc proc defaults 0 0
sysfs /sys sysfs defaults 0 0
/dev/VolGroup00/LogVol01 swap swap defaults 0 0
/dev/sdb1 /test ext3 defaults 1 1
/dev/sdb2 /test ext3 defaults 1 1
# Beginning of the block added by the VMware software
.host:/ /mnt/hgfs vmhgfs defaults,ttl=5 0 0
# End of the block added by the VMware software
The first field:Equipment name,Here is the file system representation; Sometimes we mount a file system is also said to mount the partition;
The second field:File system mount point;
The third field:File System Types;
Fourth field:Mount command options,And the mount -o empathy;These options include defaults rw, south, dev, exec, auto, nouser, async;
Fifth field:Need to dump the file system backup,1Need,0 It is not required;
Sixth field: Whether at system startup,By fsck to check the file system disk detection tools,1Need,0It is not required,2Skip;

Uninstall:
[root@localhost ~]# umount /dev/sdb1
[root@localhost ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev / mapper / VolGroup00-LogVol00
6.7G 5.8G 576M 92% /
/dev/sda1 99M 12M 82M 13% /boot
tmpfs 233M 0 233M 0% /dev/shm

 

Additional knowledge:
1. What can be used to mount the mount:
Different operating systems use different file system format。MS-DOS supports the FAT16 file system,Windows98 supports FAT16、FAT32 file system,WindowsNT支持FAT16、NTFS file system,Windows2000 supports FAT16、FAT32、NTFS three file system formats,Now xp supports FAT32, NTFS,The latest version now windows 7 It introduces a new WinFS file system。 The Linux support almost all file system format,But generally use ext2 or ext3 file system。Many users are using the windows operating system,If you want to access other file system resources to run under Linux if,We will use Linux mount command to achieve。
2. mount use format:
mount命令[-parameter] [Device Name] [Mount points]
Explanation:
[Mount points]It must be an existing directory,This directory can not be empty,But the latter mount the directory contents will not be available before,umount will return to normal after。
[Device Name] It can be a partition,A usb device,CD-ROM,floppy disk,Network sharing。
Common Parameter Description:
Mount Mount File System Help
Parameter Description
To mount the specified device type:adfs, affs, autofs, coda, coherent, cramfs,

devpts, efs, ext, ext2, ext3, hfs, hpfs, ISO9660, jfs, minix,

msdos, ncpfs, nfs, nfs4, ntfs, proc, qnx4, ramfs, reiserfs,

romfs, smbfs, sysv, tmpfs, perform, ufs, umsdos, vfat, xenix, xfs,

xiafs

General File Types,May not need to specify the same can be automatically detected (adfs, bfs,

cramfs, ext, ext2, ext3, hfs, hpfs, ISO9660, jfs, minix, ntfs,

qnx4, reiserfs, romfs, perform, ufs, vxfs, xfs, xiafs file system, etc.),Such as

If the probe fails,Will visit the / etc / filesystems ,Probe to the specified file system。Say

Bright:If you know the file system,Better to specify particular types。The catastrophic error detection

of。
Multiple file system can be used ","Splitting off.

-t vfstype mount -a -t nomsdos,ext
Fstab file will mount all file systems specified,In addition to the type msdos and ext

That some of。
Common file types
1. ext2 linux file system currently used
2. msdos MS-DOS的fat,It is fat16 vfat
3. windows98 common fat32
4. nfs Network File System
5. smbfs windows sharing system
6. iso9660 CD-ROM disc standard file system
7. ntfs windows NT / 2000 / XP file system
8. auto automatic detection of the file system
Specifies the mount system options:Multiple options can be used”,”Segmentation. Some options only appear in the file / etc / fstab the only meaningful。The following options can be used to mount any file system(But not all file systems are concerned they,E.g,Today only option to sync ext2,ext3 and ufs effective)
Option Description
async all file system I / O operations must be done asynchronously。
Atime Update inode access times at each access。This is the default option。
auto can be mounted when using the -a option。
defaults contains the following options:rw, south, dev, exec, auto, nouser,async.
dev file system parsing character or block devices。
exec allow execution of binaries
_netdev file system residing on the need for network-connected devices,Avoid disconnection under,Consumption of resources continues to mount
noatime Do not update inode access time of the file system(Enhance the speed of the news server)
noauto only be explicitly mount,-You can not mount a
nodev not parse the file system of character or block devices
noexec not allowed to be loaded in the file system any binary file
nosuid Do not allow set-user-identifier or set-group-identifier bits to work
nouser prohibited ordinary mount a file system(default)
remount attempt to remount an already-mounted file system。Tag is used to change the mount,As indicated by the read-only mount into a read-write。
ro mounted read-only
rw mounted read-write
suid Allow set-user-identifier or set-group-identifier bits to work
-o options sync in a synchronized manner for I / O operations,A sudden power failure will not be lost data,But heavier burden disk
dirsync All directory updates within the file system should be done synchronously,Affects the following system calls:creat,link, unlink, symlink, mkdir, rmdir, mknod 以及 rename
user Allow an ordinary user to mount the file system,Mount's user name is written to mtab,So that he can unmount the file system again。This option implies the options noexec,nosuid, And nodev.
users allows each user to mount unmount the file system
codepage codepage = XXX code page
iocharset iocharset = XXX character set
loop maneuver mount devices are often used to mount iso file
username username = user access device user name
Password password password = pass access device
The following parameters are only useful for special file system:
uid / gid uid = value and gid = value to specific users and groups to mount system
Permissions mask ownmask ownmask = value owner rights
Permissions mask othmask othmask = value othmask rights
Different file systems supported by the system do not necessarily attribute。You can find relevant information
-a search / etc / fstab file in the file system to meet the conditions,Be mounted operation。
format: mount -a -t type -o options do not need to specify a device / directory
-f test mount system,Only check device and directory,Not really mount a file system
-n not to mount record,Recorded in the / etc / mtab file
-r The file system is mounted as read only,with(-a ro)
-w file systems mounted for read and write,with(-about rw)
-L label Mount the partition that has the specified label in the label
-w file systems mounted for read and write,with(-about rw)
-v display detailed progress mount
-l List system has a list of all mounted file

–bind the part of the file hierarchy remounted elsewhere. Only a single file system mount,
If there are other file system directory,Will not mount。If you need to mount all,Can use:–rbind parameters。
mount –bind olddir newdir 2 can access the system directory content
–move a directory moved to another place,mount –move olddir newdir
-h Display help
-V Display version

3. Common partition load method:
mount mount iso file:
#mkdir /mnt/iso1
#mount –o loop linuxsetup.iso /mnt/iso1
In linux virtual drive is not required,You can read the iso file directly。
mount to mount the CD system
Generally CDROM device file is / dev / hdc,how to use:
#mkdir /mnt/cdrom
#mount /dev/hdc /mnt/cdrom –o iocharset=cp936
The default does not specify the drive system,You can get automatic search,The coding is specified as Chinese
mount mount Floppy Drive
# mkdir /mnt/floppy
# mount /dev/fd0 /mnt/floppy
The default does not specify a file system,You can get automatic search
mount mount windows shared files(samba)
#mkdir /mnt/winshare
#mount -t smbfs -o username=w,password=w,codepage=936,iocharset=gb2312 //192.168.0.101/share /mnt/winshare
Specifies the user name to access the shared,password,codepage specifies the encoding and iocharset same meaning。Here windows system is Chinese Simplified。
codepage specifies the file system code page,Simplified Chinese Chinese code 936;iocharset specify the character set,Simplified Chinese ships with cp936 or gb2312
mount mount u disk
If your computer is under no other SCSI devices and peripherals usb case,Insert U disk device path is / dev / sda1,Command:
#mkdir / mnt / overlay
#mount / dev / sda1 / mnt / overlay
To mount。
mount nfs mount system
Connection windows share similar。We need to configure the nfs server service。Then the client:showmount -e 192.168.0.30 You can view the connection。
mount -t nfs 192.168.0.30:/tmp /mnt/nfs
umount unmount the file system
umount dir
As described above: umout / mnt / upan or umount / dev / sdb1

Comments

XenServer create and mount the local SR ISO file storage

SSH login Xenserver。

1) Check the volume group information:
# vgdisplay

2) Write down VGname:
VG_XenStorage-a009e816-aa69-b507-71bf-b89409c63793

3) Create a logical volume allocation size and naming and formatting:
# lvcreate -L 20G -n iso VG_XenStorage-a009e816-aa69-b507-71bf-b89409c63793
# mkfs.ext3 /dev/VG_XenStorage-a009e816-aa69-b507-71bf-b89409c63793/iso

5) Create a local mount directory
# mkdir /iso

6) Edit / etc / fstab settings automatically mount the logical volume
# vi / etc / fstab

Add the following
/dev/VG_XenStorage-a009e816-aa69-b507-71bf-b89409c63793/iso /iso ext3 defaults 0 0

7) Mount the logical volume
# mount /iso

8) Create iso xenserver local library(SR store)
# xe sr-create name-label=iso type=iso device-config:location=/iso device-config:legacy_mode=true contente-type=iso

9) Xenserver mount iso
# xe-mount-iso-sr /iso -o bind

This process is completed,cd / iso wegt ISO file system,
After creating a virtual machine(VM)Time,In the process of installation media that you can choose to install to the corresponding mount iso。

#xe-toolstack-restart

Comments