LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-01-2010, 06:54 AM   #1
chaoxifer
LQ Newbie
 
Registered: Nov 2010
Location: Seoul, South Korea
Distribution: Arch, Gentoo
Posts: 15

Rep: Reputation: 0
How I implement commands "mount"?


Hi all! I newbie in Linux System.

I'm sorry for my English writing.

I study about file systems using on Linux and I try to implement file system format:ext2

I'll implement virtual disk, And format as file system - that is implemented.

So here is a problem.

I want to know that How I mount this virtual drive that I implement ?

I'm not asking detail codes, but I want to know about fundamental principle of "mount" disk.

What is the fundamental principle of "mount" disk?

Thank you for reading.

Last edited by chaoxifer; 11-01-2010 at 06:56 AM.
 
Old 11-01-2010, 07:00 AM   #2
stress_junkie
Senior Member
 
Registered: Dec 2005
Location: Massachusetts, USA
Distribution: Ubuntu 10.04 and CentOS 5.5
Posts: 3,873

Rep: Reputation: 335Reputation: 335Reputation: 335Reputation: 335
The man page for mount provides a lot of information. So much so that it can be difficult to find what you want in the large amount of information.

Basically the format for mount is

mount file-system-type device-to-mount mount-point

An example to mount /dev/sda5 on /mnt/sda5 would be

Code:
mount -t ext2 /dev/sda5 /mnt/sda5
Normally only root can mount partitions.
So that is the fundamental principle of mount.
 
Old 11-01-2010, 07:07 AM   #3
chaoxifer
LQ Newbie
 
Registered: Nov 2010
Location: Seoul, South Korea
Distribution: Arch, Gentoo
Posts: 15

Original Poster
Rep: Reputation: 0
Just "mount" command, is that all?

Quote:
Originally Posted by stress_junkie View Post
The man page for mount provides a lot of information. So much so that it can be difficult to find what you want in the large amount of information.

Basically the format for mount is

mount file-system-type device-to-mount mount-point

An example to mount /dev/sda5 on /mnt/sda5 would be

Code:
mount -t ext2 /dev/sda5 /mnt/sda5
Normally only root can mount partitions.
So that is the fundamental principle of mount.
Thanks for replying.

There is no need to implement "mount" and I just use "mount" command If I finished implement virtual disk formatted as ext2?
 
Old 11-01-2010, 07:19 AM   #4
stress_junkie
Senior Member
 
Registered: Dec 2005
Location: Massachusetts, USA
Distribution: Ubuntu 10.04 and CentOS 5.5
Posts: 3,873

Rep: Reputation: 335Reputation: 335Reputation: 335Reputation: 335
If you want to manually mount a partition then you can use the mount command.

If you want the partition to automatically mount when the system starts then you put an entry for that partition in the /etc/fstab file.

What is this virtual disk? Is it a partition or is it a file on another partition? If you have questions about using the virtual disk then you will have to describe what that is and how you created it.
 
Old 11-01-2010, 07:37 AM   #5
chaoxifer
LQ Newbie
 
Registered: Nov 2010
Location: Seoul, South Korea
Distribution: Arch, Gentoo
Posts: 15

Original Poster
Rep: Reputation: 0
I mean the virtual disk is a file on another partition.

Quote:
Originally Posted by stress_junkie View Post
If you want to manually mount a partition then you can use the mount command.

If you want the partition to automatically mount when the system starts then you put an entry for that partition in the /etc/fstab file.

What is this virtual disk? Is it a partition or is it a file on another partition? If you have questions about using the virtual disk then you will have to describe what that is and how you created it.
Like .vdi file on virtual box - I use "virtual disk" as a file on another partition. I don't know correct term about that... Sorry,,,

Anyway, Thank you for your reply. I need to more study..
 
Old 11-01-2010, 07:43 AM   #6
stress_junkie
Senior Member
 
Registered: Dec 2005
Location: Massachusetts, USA
Distribution: Ubuntu 10.04 and CentOS 5.5
Posts: 3,873

Rep: Reputation: 335Reputation: 335Reputation: 335Reputation: 335
You can mount a file that contains a file system using the loop option in the mount command.

Code:
mount -t ext2 -o loop virtualdisk.bin /mnt/vdisk
Naturally the /mnt/vdisk directory has to exist.

You can also use the loop option in the /etc/fstab file so that the virtual disk is mounted automatically during system startup.

Last edited by stress_junkie; 11-01-2010 at 07:47 AM.
 
Old 11-01-2010, 07:47 AM   #7
chaoxifer
LQ Newbie
 
Registered: Nov 2010
Location: Seoul, South Korea
Distribution: Arch, Gentoo
Posts: 15

Original Poster
Rep: Reputation: 0
^ㅡ^ Thank u so much

Quote:
Originally Posted by stress_junkie View Post
You can mount a file that has a file system using the loop option in the mount command.

Code:
mount -t ext2 -o loop virtualdisk.bin /mnt/vdisk
Naturally the /mnt/vdisk directory has to exist.

You can also use the loop option in the /etc/fstab file so that the virtual disk is mounted automatically during system startup.
I really appreciate about your reply.

I'll try it
 
Old 11-01-2010, 04:40 PM   #8
stress_junkie
Senior Member
 
Registered: Dec 2005
Location: Massachusetts, USA
Distribution: Ubuntu 10.04 and CentOS 5.5
Posts: 3,873

Rep: Reputation: 335Reputation: 335Reputation: 335Reputation: 335
All right. Here is how to create, format, and mount a container file as a virtual disk.

First create the container file. This one will be 4 GB
Code:
$ dd if=/dev/zero of=test.bin bs=4096 count=1M
1048576+0 records in
1048576+0 records out
4294967296 bytes (4.3 GB) copied, 94.352 s, 45.5 MB/s
Second, attach the container file onto a loop device. This has to be done as root so I use su to log on as root. Once it is attached to a loop device you can create a file system in it using mkfs.
Code:
$ su

# /sbin/losetup  /dev/loop0 test.bin

# mkfs -t ext3 /dev/loop0
Those steps only have to be performed once.

Now if you want to mount it do this. Note that you will only have to perform the losetup command if you have detached the container file such as when you restart the computer.
Code:
# /sbin/losetup  /dev/loop0 test.bin

# mount -t ext3 /dev/loop0 /mnt/vdisk
Also note that /mnt/vdisk had to already exist.

Now you can use the mount command with no parameters to list all of the mounted devices. Your virtual disk should show up in this list.
Code:
# mount
...
/dev/loop0 on /mnt/vdisk type ext3 (rw)
I hope this helps.

Last edited by stress_junkie; 11-01-2010 at 04:46 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Getting bash to login as root and recognize commands like "vi" and "locate" ajaygoeslinux Linux - Software 4 05-04-2009 10:51 PM
Standard commands give "-bash: open: command not found" even in "su -" and "su root" mibo12 Linux - General 4 11-11-2007 10:18 PM
"clear" and "reset" bash commands broken AviJacobson Linux - General 6 07-03-2006 06:28 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:47 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration