How to create a real RAM disk that reserves memory?
Clash Royale CLAN TAG#URR8PPP
up vote
2
down vote
favorite
I've been shortly using the following on Linux Debian Jessie to create a "RAM disk":
mount -o size=1G -t tmpfs none /mnt/tmpfs
But I was told it doesn't reserve memory, which I didn't know.
I would like a solution, which does reserve memory.
tmpfs ramdisk
add a comment |Â
up vote
2
down vote
favorite
I've been shortly using the following on Linux Debian Jessie to create a "RAM disk":
mount -o size=1G -t tmpfs none /mnt/tmpfs
But I was told it doesn't reserve memory, which I didn't know.
I would like a solution, which does reserve memory.
tmpfs ramdisk
add a comment |Â
up vote
2
down vote
favorite
up vote
2
down vote
favorite
I've been shortly using the following on Linux Debian Jessie to create a "RAM disk":
mount -o size=1G -t tmpfs none /mnt/tmpfs
But I was told it doesn't reserve memory, which I didn't know.
I would like a solution, which does reserve memory.
tmpfs ramdisk
I've been shortly using the following on Linux Debian Jessie to create a "RAM disk":
mount -o size=1G -t tmpfs none /mnt/tmpfs
But I was told it doesn't reserve memory, which I didn't know.
I would like a solution, which does reserve memory.
tmpfs ramdisk
tmpfs ramdisk
edited Apr 15 at 8:59
asked Oct 26 '15 at 23:23
Vlastimil
6,8411149124
6,8411149124
add a comment |Â
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
1
down vote
accepted
Add it to your /etc/fstab
:
none /mnt/tmpfs tmpfs defaults,size=1g,mode=1777 0 0
You may also need to rebuild your initramfs, e.g.:
sudo update-initramfs -u -k $(uname -r)
or, to rebuild the initramfs for all kernels:
sudo update-initramfs -u -k all
BTW, tmpfs doesn't reserve any memory - a tmpfs filesystem only uses as much memory as required by the files it contains (and any file/directory overhead).
why do you need to update initramfs?
â mikeserv
Oct 27 '15 at 0:20
so that the tmpfs is mounted and available very early in the boot process. if that's not required then there's no need to update the initramfs just for that - but apart from taking a little time, there's no harm in doing it. it will get done next time the kernel is updated or something else triggers an update-initramfs
â cas
Oct 27 '15 at 0:22
how can it be mounted any sooner than/
?
â mikeserv
Oct 27 '15 at 0:23
Note, that there is no need forupdate-initramfs
, consider removing it from your answer for future readers.
â Vlastimil
Sep 27 at 22:56
add a comment |Â
up vote
0
down vote
In fact it does not reserve any memory. That behaviour was present when using ramdisks initiated at boot time, but it was removed a long time ago.
Currently, only the kernel and its modules can allocate a specific RAM region, or reserve an actual RAM area. Other methods will allocate memory which can be swapped to disk.
My previous answer suggested allocating a file over a tmpfs mount point, which was then mounted as a loopback device. While it works at pre-allocating memory for the purpose of a "ramdisk", its content will be swapped, and the solution will not work if there is any swap enabled.
Btw, this works at allocating memory because tmpfs only allocates memory as it is required to store the files it contains, which happens when the disk file is created.
----------------- Non working solution ------------------------------
One thing you could do is to create a loopback file with the desired size inside the tmpfs.
It would be something like this:
mount -o size=1G -t tmpfs none /mnt/tmpfs
dd if=/dev/zero of=/mnt/tmpfs/disk
losetup /dev/loop0 /mnt/tmpfs/disk
mkfs.ext2 /dev/loop0
mount /dev/loop0 /mnt/static_ramdisk
use ramfs in place of tmpfs, or use brd. unix.stackexchange.com/questions/66329/⦠unix.stackexchange.com/questions/433712/â¦
â sourcejedi
Sep 28 at 0:32
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
Add it to your /etc/fstab
:
none /mnt/tmpfs tmpfs defaults,size=1g,mode=1777 0 0
You may also need to rebuild your initramfs, e.g.:
sudo update-initramfs -u -k $(uname -r)
or, to rebuild the initramfs for all kernels:
sudo update-initramfs -u -k all
BTW, tmpfs doesn't reserve any memory - a tmpfs filesystem only uses as much memory as required by the files it contains (and any file/directory overhead).
why do you need to update initramfs?
â mikeserv
Oct 27 '15 at 0:20
so that the tmpfs is mounted and available very early in the boot process. if that's not required then there's no need to update the initramfs just for that - but apart from taking a little time, there's no harm in doing it. it will get done next time the kernel is updated or something else triggers an update-initramfs
â cas
Oct 27 '15 at 0:22
how can it be mounted any sooner than/
?
â mikeserv
Oct 27 '15 at 0:23
Note, that there is no need forupdate-initramfs
, consider removing it from your answer for future readers.
â Vlastimil
Sep 27 at 22:56
add a comment |Â
up vote
1
down vote
accepted
Add it to your /etc/fstab
:
none /mnt/tmpfs tmpfs defaults,size=1g,mode=1777 0 0
You may also need to rebuild your initramfs, e.g.:
sudo update-initramfs -u -k $(uname -r)
or, to rebuild the initramfs for all kernels:
sudo update-initramfs -u -k all
BTW, tmpfs doesn't reserve any memory - a tmpfs filesystem only uses as much memory as required by the files it contains (and any file/directory overhead).
why do you need to update initramfs?
â mikeserv
Oct 27 '15 at 0:20
so that the tmpfs is mounted and available very early in the boot process. if that's not required then there's no need to update the initramfs just for that - but apart from taking a little time, there's no harm in doing it. it will get done next time the kernel is updated or something else triggers an update-initramfs
â cas
Oct 27 '15 at 0:22
how can it be mounted any sooner than/
?
â mikeserv
Oct 27 '15 at 0:23
Note, that there is no need forupdate-initramfs
, consider removing it from your answer for future readers.
â Vlastimil
Sep 27 at 22:56
add a comment |Â
up vote
1
down vote
accepted
up vote
1
down vote
accepted
Add it to your /etc/fstab
:
none /mnt/tmpfs tmpfs defaults,size=1g,mode=1777 0 0
You may also need to rebuild your initramfs, e.g.:
sudo update-initramfs -u -k $(uname -r)
or, to rebuild the initramfs for all kernels:
sudo update-initramfs -u -k all
BTW, tmpfs doesn't reserve any memory - a tmpfs filesystem only uses as much memory as required by the files it contains (and any file/directory overhead).
Add it to your /etc/fstab
:
none /mnt/tmpfs tmpfs defaults,size=1g,mode=1777 0 0
You may also need to rebuild your initramfs, e.g.:
sudo update-initramfs -u -k $(uname -r)
or, to rebuild the initramfs for all kernels:
sudo update-initramfs -u -k all
BTW, tmpfs doesn't reserve any memory - a tmpfs filesystem only uses as much memory as required by the files it contains (and any file/directory overhead).
edited Sep 27 at 23:19
Vlastimil
6,8411149124
6,8411149124
answered Oct 27 '15 at 0:18
cas
38k44495
38k44495
why do you need to update initramfs?
â mikeserv
Oct 27 '15 at 0:20
so that the tmpfs is mounted and available very early in the boot process. if that's not required then there's no need to update the initramfs just for that - but apart from taking a little time, there's no harm in doing it. it will get done next time the kernel is updated or something else triggers an update-initramfs
â cas
Oct 27 '15 at 0:22
how can it be mounted any sooner than/
?
â mikeserv
Oct 27 '15 at 0:23
Note, that there is no need forupdate-initramfs
, consider removing it from your answer for future readers.
â Vlastimil
Sep 27 at 22:56
add a comment |Â
why do you need to update initramfs?
â mikeserv
Oct 27 '15 at 0:20
so that the tmpfs is mounted and available very early in the boot process. if that's not required then there's no need to update the initramfs just for that - but apart from taking a little time, there's no harm in doing it. it will get done next time the kernel is updated or something else triggers an update-initramfs
â cas
Oct 27 '15 at 0:22
how can it be mounted any sooner than/
?
â mikeserv
Oct 27 '15 at 0:23
Note, that there is no need forupdate-initramfs
, consider removing it from your answer for future readers.
â Vlastimil
Sep 27 at 22:56
why do you need to update initramfs?
â mikeserv
Oct 27 '15 at 0:20
why do you need to update initramfs?
â mikeserv
Oct 27 '15 at 0:20
so that the tmpfs is mounted and available very early in the boot process. if that's not required then there's no need to update the initramfs just for that - but apart from taking a little time, there's no harm in doing it. it will get done next time the kernel is updated or something else triggers an update-initramfs
â cas
Oct 27 '15 at 0:22
so that the tmpfs is mounted and available very early in the boot process. if that's not required then there's no need to update the initramfs just for that - but apart from taking a little time, there's no harm in doing it. it will get done next time the kernel is updated or something else triggers an update-initramfs
â cas
Oct 27 '15 at 0:22
how can it be mounted any sooner than
/
?â mikeserv
Oct 27 '15 at 0:23
how can it be mounted any sooner than
/
?â mikeserv
Oct 27 '15 at 0:23
Note, that there is no need for
update-initramfs
, consider removing it from your answer for future readers.â Vlastimil
Sep 27 at 22:56
Note, that there is no need for
update-initramfs
, consider removing it from your answer for future readers.â Vlastimil
Sep 27 at 22:56
add a comment |Â
up vote
0
down vote
In fact it does not reserve any memory. That behaviour was present when using ramdisks initiated at boot time, but it was removed a long time ago.
Currently, only the kernel and its modules can allocate a specific RAM region, or reserve an actual RAM area. Other methods will allocate memory which can be swapped to disk.
My previous answer suggested allocating a file over a tmpfs mount point, which was then mounted as a loopback device. While it works at pre-allocating memory for the purpose of a "ramdisk", its content will be swapped, and the solution will not work if there is any swap enabled.
Btw, this works at allocating memory because tmpfs only allocates memory as it is required to store the files it contains, which happens when the disk file is created.
----------------- Non working solution ------------------------------
One thing you could do is to create a loopback file with the desired size inside the tmpfs.
It would be something like this:
mount -o size=1G -t tmpfs none /mnt/tmpfs
dd if=/dev/zero of=/mnt/tmpfs/disk
losetup /dev/loop0 /mnt/tmpfs/disk
mkfs.ext2 /dev/loop0
mount /dev/loop0 /mnt/static_ramdisk
use ramfs in place of tmpfs, or use brd. unix.stackexchange.com/questions/66329/⦠unix.stackexchange.com/questions/433712/â¦
â sourcejedi
Sep 28 at 0:32
add a comment |Â
up vote
0
down vote
In fact it does not reserve any memory. That behaviour was present when using ramdisks initiated at boot time, but it was removed a long time ago.
Currently, only the kernel and its modules can allocate a specific RAM region, or reserve an actual RAM area. Other methods will allocate memory which can be swapped to disk.
My previous answer suggested allocating a file over a tmpfs mount point, which was then mounted as a loopback device. While it works at pre-allocating memory for the purpose of a "ramdisk", its content will be swapped, and the solution will not work if there is any swap enabled.
Btw, this works at allocating memory because tmpfs only allocates memory as it is required to store the files it contains, which happens when the disk file is created.
----------------- Non working solution ------------------------------
One thing you could do is to create a loopback file with the desired size inside the tmpfs.
It would be something like this:
mount -o size=1G -t tmpfs none /mnt/tmpfs
dd if=/dev/zero of=/mnt/tmpfs/disk
losetup /dev/loop0 /mnt/tmpfs/disk
mkfs.ext2 /dev/loop0
mount /dev/loop0 /mnt/static_ramdisk
use ramfs in place of tmpfs, or use brd. unix.stackexchange.com/questions/66329/⦠unix.stackexchange.com/questions/433712/â¦
â sourcejedi
Sep 28 at 0:32
add a comment |Â
up vote
0
down vote
up vote
0
down vote
In fact it does not reserve any memory. That behaviour was present when using ramdisks initiated at boot time, but it was removed a long time ago.
Currently, only the kernel and its modules can allocate a specific RAM region, or reserve an actual RAM area. Other methods will allocate memory which can be swapped to disk.
My previous answer suggested allocating a file over a tmpfs mount point, which was then mounted as a loopback device. While it works at pre-allocating memory for the purpose of a "ramdisk", its content will be swapped, and the solution will not work if there is any swap enabled.
Btw, this works at allocating memory because tmpfs only allocates memory as it is required to store the files it contains, which happens when the disk file is created.
----------------- Non working solution ------------------------------
One thing you could do is to create a loopback file with the desired size inside the tmpfs.
It would be something like this:
mount -o size=1G -t tmpfs none /mnt/tmpfs
dd if=/dev/zero of=/mnt/tmpfs/disk
losetup /dev/loop0 /mnt/tmpfs/disk
mkfs.ext2 /dev/loop0
mount /dev/loop0 /mnt/static_ramdisk
In fact it does not reserve any memory. That behaviour was present when using ramdisks initiated at boot time, but it was removed a long time ago.
Currently, only the kernel and its modules can allocate a specific RAM region, or reserve an actual RAM area. Other methods will allocate memory which can be swapped to disk.
My previous answer suggested allocating a file over a tmpfs mount point, which was then mounted as a loopback device. While it works at pre-allocating memory for the purpose of a "ramdisk", its content will be swapped, and the solution will not work if there is any swap enabled.
Btw, this works at allocating memory because tmpfs only allocates memory as it is required to store the files it contains, which happens when the disk file is created.
----------------- Non working solution ------------------------------
One thing you could do is to create a loopback file with the desired size inside the tmpfs.
It would be something like this:
mount -o size=1G -t tmpfs none /mnt/tmpfs
dd if=/dev/zero of=/mnt/tmpfs/disk
losetup /dev/loop0 /mnt/tmpfs/disk
mkfs.ext2 /dev/loop0
mount /dev/loop0 /mnt/static_ramdisk
edited Oct 30 '15 at 15:54
answered Oct 27 '15 at 0:02
OluaJho
8412
8412
use ramfs in place of tmpfs, or use brd. unix.stackexchange.com/questions/66329/⦠unix.stackexchange.com/questions/433712/â¦
â sourcejedi
Sep 28 at 0:32
add a comment |Â
use ramfs in place of tmpfs, or use brd. unix.stackexchange.com/questions/66329/⦠unix.stackexchange.com/questions/433712/â¦
â sourcejedi
Sep 28 at 0:32
use ramfs in place of tmpfs, or use brd. unix.stackexchange.com/questions/66329/⦠unix.stackexchange.com/questions/433712/â¦
â sourcejedi
Sep 28 at 0:32
use ramfs in place of tmpfs, or use brd. unix.stackexchange.com/questions/66329/⦠unix.stackexchange.com/questions/433712/â¦
â sourcejedi
Sep 28 at 0:32
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f238810%2fhow-to-create-a-real-ram-disk-that-reserves-memory%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password