LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop
User Name
Password
Linux - Desktop This forum is for the discussion of all Linux Software used in a desktop context.

Notices


Reply
  Search this Thread
Old 04-05-2010, 01:47 PM   #1
ahalabb
LQ Newbie
 
Registered: Oct 2007
Posts: 13

Rep: Reputation: 0
Run / from RAM


I want to create a RAM disk - say 8GB. I want to copy SDA1 partition or data to RAM. Then remount / under the 8GB RAM.

I am figuring out how to do this.

-comments
 
Old 04-05-2010, 02:14 PM   #2
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,634

Rep: Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965
Quote:
Originally Posted by ahalabb View Post
I want to create a RAM disk - say 8GB. I want to copy SDA1 partition or data to RAM. Then remount / under the 8GB RAM.
I am figuring out how to do this.
-comments
Well, good. Have fun.
 
Old 04-05-2010, 06:47 PM   #3
ahalabb
LQ Newbie
 
Registered: Oct 2007
Posts: 13

Original Poster
Rep: Reputation: 0
I have the RAM disk. Default is 50% RAM.

mount -t tmpfs /mnt

Using dd didn't work out so well. I was able to copy the root files to the RAM drive. But I'm stuck at unmounting /
 
Old 04-06-2010, 12:50 AM   #4
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
Look at the chroot command. You are trying to do the reverse of what happens when you boot and the root pivots from initrd to the newly mounted root partition.

If you want to run in ram, maybe the best way is to create an initrd file similar to a rescue disk which stays in memory.

I don't see why you want to do this. You will be wasting memory trying to do what caching achieves
at less cost.

Last edited by jschiwal; 04-06-2010 at 12:54 AM.
 
Old 04-06-2010, 12:17 PM   #5
ahalabb
LQ Newbie
 
Registered: Oct 2007
Posts: 13

Original Poster
Rep: Reputation: 0
thanks, initrd is what i am focusing on.

as for why - an 4\8GBfilesystem [in RAM] is more than i need for daily use. if files are in RAM and programs load in RAM there is no hard drive-aside from booting-, the computer runs much faster than an array of SSDs.

its all about performance

Last edited by ahalabb; 04-06-2010 at 12:18 PM.
 
Old 04-06-2010, 12:24 PM   #6
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,634

Rep: Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965
Quote:
Originally Posted by ahalabb View Post
thanks, initrd is what i am focusing on.

as for why - an 4\8GBfilesystem [in RAM] is more than i need for daily use. if files are in RAM and programs load in RAM there is no hard drive-aside from booting-, the computer runs much faster than an array of SSDs.
If you say so...
Quote:
its all about performance
Which your solution won't give you. Think about what you're actually doing, and how, and you'll know why.
 
1 members found this post helpful.
Old 04-07-2010, 11:30 AM   #7
ahalabb
LQ Newbie
 
Registered: Oct 2007
Posts: 13

Original Poster
Rep: Reputation: 0
my simple view

Hard drive = ~50MB/read.write 8ms latency
RAM = ~10,000MB/read.write 0.01ms latency

According to you I am missing something.
 
Old 04-07-2010, 11:45 AM   #8
Quakeboy02
Senior Member
 
Registered: Nov 2006
Distribution: Debian Linux 11 (Bullseye)
Posts: 3,407

Rep: Reputation: 141Reputation: 141
What do you get when you run your test against the hard disk multiple times?
 
Old 04-07-2010, 12:08 PM   #9
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,634

Rep: Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965
Quote:
Originally Posted by ahalabb View Post
Hard drive = ~50MB/read.write 8ms latency
RAM = ~10,000MB/read.write 0.01ms latency

According to you I am missing something.
Quite a bit, apparently. Hardware latency is a small part of the system as a whole.

Read about WHY SSD drives are so expensive, and why (since they've been around for many years), are only now coming to where consumers can afford them, even though RAM is very cheap.
 
Old 04-09-2010, 01:09 AM   #10
ahalabb
LQ Newbie
 
Registered: Oct 2007
Posts: 13

Original Poster
Rep: Reputation: 0
I added "ramdisk_size" kernel parameter to make 512MB.
I used mkfs to put ext4 on it and mounted.

I have been playing around with running programs from RAM. But running / from my RAM disk is going to be a project.



---edit
this is what i was looking for

http://linux.die.net/man/8/pivot_root
http://linux.die.net/man/4/initrd


Last edited by ahalabb; 04-09-2010 at 02:17 AM.
 
Old 04-10-2010, 02:02 PM   #11
Quakeboy02
Senior Member
 
Registered: Nov 2006
Distribution: Debian Linux 11 (Bullseye)
Posts: 3,407

Rep: Reputation: 141Reputation: 141
What results do you get when you run your timing test on your hard disk multiple times?
 
Old 04-11-2010, 11:11 PM   #12
ahalabb
LQ Newbie
 
Registered: Oct 2007
Posts: 13

Original Poster
Rep: Reputation: 0
Consistent, givertake a couple MB. Not so much focus on that - either way the HD is over 10 times slower.

Benching the ramdisk I get ~700MB/s read.
But reading from linux buffer, I get 2500MB/s

I assume there is more work to do with the ramdisk than reading directly from RAM?
 
Old 04-16-2010, 03:41 AM   #13
pix9
Member
 
Registered: Jan 2010
Location: Mumbai, India
Distribution: ArchLinux, Fedora 24, Centos 7.0
Posts: 177

Rep: Reputation: 19
this seems intresting
 
Old 04-16-2010, 07:15 AM   #14
GazL
LQ Veteran
 
Registered: May 2008
Posts: 6,897

Rep: Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018
Setup:
Code:
root@nix:~# mount -t tmpfs tmpfs2 /mnt
root@nix:~# mount
/dev/rootvg/lvroot on / type ext4 (rw,relatime,barrier=1,data=ordered)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
usbfs on /proc/bus/usb type usbfs (rw)
/dev/sda1 on /boot type ext2 (rw,relatime)
/dev/mapper/rootvg-lvusr on /usr type ext4 (rw,relatime)
/dev/mapper/rootvg-lvopt on /opt type ext4 (rw,relatime)
/dev/mapper/rootvg-lvvar on /var type ext4 (rw,relatime)
/dev/mapper/rootvg-lvtmp on /tmp type ext4 (rw,relatime)
/dev/mapper/rootvg-lvhome on /home type ext4 (rw,relatime)
/dev/mapper/rootvg-lvlocal on /local type ext4 (rw,relatime)
tmpfs on /dev/shm type tmpfs (rw)
tmpfs2 on /mnt type tmpfs (rw)
root@nix:~# dd if=/dev/urandom bs=1048576 count=256 of=/mnt/wibble.data
256+0 records in
256+0 records out
268435456 bytes (268 MB) copied, 33.6394 s, 8.0 MB/s
root@nix:~# cp /mnt/wibble.data /tmp/wibble.data
root@nix:~# sync
root@nix:~# sync
benchmark tmpfs:
Code:
root@nix:~# dd if=/mnt/wibble.data of=/dev/null
524288+0 records in
524288+0 records out
268435456 bytes (268 MB) copied, 0.292685 s, 917 MB/s
root@nix:~# dd if=/mnt/wibble.data of=/dev/null
524288+0 records in
524288+0 records out
268435456 bytes (268 MB) copied, 0.304778 s, 881 MB/s
root@nix:~# dd if=/mnt/wibble.data of=/dev/null
524288+0 records in
524288+0 records out
268435456 bytes (268 MB) copied, 0.299991 s, 895 MB/s
benchmark ext4 on disk:
Code:
root@nix:~# dd if=/tmp/wibble.data of=/dev/null
524288+0 records in
524288+0 records out
268435456 bytes (268 MB) copied, 0.276751 s, 970 MB/s
root@nix:~# dd if=/tmp/wibble.data of=/dev/null
524288+0 records in
524288+0 records out
268435456 bytes (268 MB) copied, 0.258143 s, 1.0 GB/s
root@nix:~# dd if=/tmp/wibble.data of=/dev/null
524288+0 records in
524288+0 records out
268435456 bytes (268 MB) copied, 0.277482 s, 967 MB/s
Reads from ext4 on disk via buffers do appear to be slightly faster than tmpfs in this basic example. Of course, this assumes that the data is already resident and manages to stay in filesystem cache.


I believe that unlike tmpfs, ramfs also goes through the vfs cache, and a test run against a ramfs mounted partition shows comparable results to the on-disk test, which seems to confirm this.
Code:
root@nix:~# dd if=/mnt/wibble.data of=/dev/null
524288+0 records in
524288+0 records out
268435456 bytes (268 MB) copied, 0.283992 s, 945 MB/s
root@nix:~# dd if=/mnt/wibble.data of=/dev/null
524288+0 records in
524288+0 records out
268435456 bytes (268 MB) copied, 0.264472 s, 1.0 GB/s
root@nix:~# dd if=/mnt/wibble.data of=/dev/null
524288+0 records in
524288+0 records out
268435456 bytes (268 MB) copied, 0.269133 s, 997 MB/s

Last edited by GazL; 04-16-2010 at 08:06 AM.
 
  


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
Run Linux in RAM v1pEr Linux - General 13 12-27-2011 04:04 PM
Run linux from ram officecase Linux - Server 2 07-21-2009 06:28 PM
how do liveCDs run, if not in RAM? newbiesforever Linux - General 2 02-01-2009 02:17 PM
Run from RAM... /bin/false Linux - Hardware 5 04-30-2007 07:02 AM
distro to run X on a P133 48 MB ram macubo Linux - Distributions 6 01-24-2006 05:15 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop

All times are GMT -5. The time now is 06:30 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