Category PS4 Jailbreaking       Thread starter PSXHAX       Start date Jan 8, 2017 at 12:59 AM       15,196       20            
Recently we saw Vulkan on PS4 Linux and PS4 Linux Gentoo Portage, and now following news of the PS4 Pro 0Day Exploit comes PS4 Linux support in development for the PS4 Pro kernel via Fail0verflow's GIT for Sony's PlayStation 4 Pro console! <3

Download: ps4-linux-ps4pro.zip / GIT

Code:
#!/boot/bzImage

# Linux kernel initialization code, translated to bash
# (Minus floppy disk handling, because seriously, it's 2017.)
# Not 100% accurate, but gives you a good idea of how kernel init works
# GPLv2, Copyright 2017 Hector Martin <[email protected]>
# Based on Linux 4.10-rc2.

# Note: pretend chroot is a builtin and affects the current process
# Note: kernel actually uses major/minor device numbers instead of device name
#       strings in a few places, but I simplified it by using strings
#       everywhere even though that is not completely accurate.

panic() {
    echo "$*"
    while true; do
        sleep 1
    done
}

do_mount_root() {
    mount -t $2 "$1" /root $rootflags || return $?
    cd /root
    echo "VFS: Mounted root ($2 filesystem) on device $major:$minor"
}

mount_block_root() {
    if [ -z $rootfstype ]; then
        rootfstype=$built_in_filesystem_types
    fi
    for fs in ${rootfstype//,/ }; do
        do_mount_root $1 $fs
        ret=$?
        case $ret in
            13|22) # EACCES or EINVAL
                ;;
            *)
                echo "VFS: Cannot open root device \"$root_device_name\" or $1: error $ret"
                echo "Please append a correct \"root=\" boot option; here are the available partitions:"
                printk_all_partitions
                panic "VFS: Unable to mount root fs on $1"
        esac
    done
    echo "List of all partitions:"
    printk_all_partitions
    echo "No filesystem could mount root, tried: ${rootfstype//,/ }"
    panic "VFS: Unable to mount root fs on $1"
}

mount_root() {
    if [ "$root" = "/dev/nfs" ]; then
        mount_nfs_root && return
        echo "VFS: Unable to mount root fs via NFS, trying floppy."
        root=/dev/fd0
    fi
    if [ "$root" = "/dev/fd0" ]; then
        # floppy switching nonsense
    fi
    # This is really a mknod, as the kernel is working with the device number
    cp -a "$root" /dev/root || echo "Failed to create /dev/root: $?"
    mount_block_root /dev/root
}

rd_load_image() {
    # Supports more compression algorithms in practice
    gzip -d <$1 >/dev/ram || cat $1 >/dev/ram
    # Bunch of nonsense special casing for floppies skipped
    # Also apparently S/390 gets special cased a cute spinner here...
}

initrd_load() {
    mknod /dev/ram b 1 0
    if rd_load_image /initrd.image && [ "$root" != "/dev/ram0" ]; then
        # This is the deprecated "change_root" mechanism; see Documentation/initrd.txt for details.
        # In this mode, the initrd should contain /linuxrc and it is *not* responsible for mounting the rootfs.
        rm /initrd.image
        mknod /dev/root.old b 1 0
        # mount initrd on rootfs' /root
        mount_block_root /dev/root.old
        mkdir /old
        cd /old
        # try loading default modules from initrd
        load_default_modules
        (
            exec </dev/console >&0 2>&0
            cd /root
            mount --move . /
            chroot .
            setsid /linuxrc
        )
        # move initrd to rootfs' /old
        mount --move .. .
        # switch root and cwd back to / of rootfs
        chroot ..
        cd /
        mount_root
        echo -n "Trying to move old root to /initrd ... "
        mount --move /old /root/initrd
        ret=$?
        if [ $ret = 0 ]; then
            echo "okay"
        else
            if [ $ret = 2 ]; then # ENOENT
                echo "/initrd does not exit. Ignored."
            else
                echo "failed"
            fi
            echo "Unmounting old root"
            umount -l /old
            echo -n "Trying to free ramdisk memory ... "
            blockdev --flushbufs /dev/root.old && echo "okay" || echo "failed"
        if
        return 0
    else
        # Otherwise, if root=/dev/ram0, this is the "new" "pivot_root" initrd mechanism.
        # The initrd is just mounted like any other root FS and $init is called in it.
        # See Documentation/initrd.txt for what the initrd has to do in this case.
        # Note that this is obsolete too in the more recent initramfs case.
        rm /initrd.image
        return 1
    fi
}

prepare_namespace() {
    if [ ! -z "$rootdelay" ]; then
        echo "Waiting $rootdelay sec before mounting root device..."
        sleep $rootdelay
    fi
    wait_for_device_probe # wait for devices
    md_run_setup # md-raid autoconfig

    if [ ! -z "$root" ]; then
        case "$root" in
            mtd*|ubi*)
                mount_block_root "$root"
                mount -t devtmpfs devtmpfs dev  # only if CONFIG_DEVTMPFS_MOUNT
                mount --move . /
                chroot .
                return
                ;;
        esac
        root_device_name="${root##/dev/}"
    fi
    if ! initrd_load; then
        if [ ! -z $root_wait ]; then
            echo "Waiting for root device $root..."
            while ! driver_probe_done || [ ! -e $root ]; do
                sleep 1
            done
        fi
        mount_root
    fi
    mount -t devtmpfs devtmpfs dev  # only if CONFIG_DEVTMPFS_MOUNT
    mount --move . /
    chroot .
}

populate_rootfs() {
    ## default initramfs
    cd /
    mkdir /dev
    mknod /dev/console c 5 1
    mkdir /root

    ## additional kernel built-in initramfs contents (not a real device)
    cpio -i < /dev/internal_initramfs

    ## note: /dev/initrd isn't a real device but represents the initrd memory
    ## /initrd.image is a real file on rootfs
    if [ -e /dev/initrd ]; then
        echo "Trying to unpack rootfs image as initramfs..."
        ## actual kernel code for cpio can deal with compression & concatenation
        if ! cpio -i < /dev/initrd; then
            echo "rootfs image is not an initramfs; looks like an initrd"
            cp /dev/initrd /initrd.image
        fi
        free_initrd # gets rid of /dev/initrd
        # Try loading default modules from initramfs.  This gives
        # us a chance to load before device_initcalls.       
        load_default_modules
    fi
}

kernel_init() {
    early_kernel_init
    # Note: at this point, as part of basic VFS init, a rootfs (special tmpfs) is mounted at /
    populate_rootfs
    more_kernel_init

    # Open the /dev/console on the rootfs, this should never fail
    exec </dev/console >&0 2>&0 || echo "Warning: unable to open an initial console."

    # check if there is an early userspace init.  If yes, let it do all the work
    if [ -z "$rdinit" ]; then
        rdinit=/init
    fi

    if [ ! -e "$rdinit" ]; then
        rdinit=
        # Mount root, the whole shebang.
        # Only done if there is *no* $rdinit (/init) in the initramfs!
        prepare_namespace
    fi

    # Ok, we have completed the initial bootup, and
    # we're essentially up and running. Get rid of the
    # initmem segments and start the user-mode stuff..
    #
    # rootfs is available now, try loading the public keys
    # and default modules
    integrity_load_keys
    load_default_modules

    late_kernel_init

    if [ ! -z "$rdinit" ]; then
        # If present in the initramfs, $rdinit (/init) is responsible
        # for *everything*, and this is the modern way of doing things.
        # To find out what $rdinit has to do in that case, read
        # Documentation/filesystems/ramfs-rootfs-initramfs.txt
        exec $rdinit
        echo "Failed to execute $rdinit (error $?)"
    fi

    if [ ! -z "$init" ]; then
        # This could be the real /sbin/init, or an initrd /sbin/init.
        exec $init
        echo "Requested init $init failed (error $?)"
    fi

    exec /sbin/init || exec /etc/init || exec /bin/init || exec /bin/sh

    panic "No working init found.  Try passing init= option to kernel. See Linux Documentation/admin-guide/init.rst for guidance."
}

kernel_init
Cheers to @Nesterwork in the Shoutbox and @romantizma for the heads-up in the PSXHAX Forum on this PlayStation 4 Linux news tip! :beer:

PS4 Linux Support in PlayStation 4 Pro Kernel on Fail0verflow GIT.jpg
 

Comments

DawgY

Member
Contributor
Seems Mathieu wasn't full of crap after all. Thanks to his suggestion, I have a PS4 Pro on v3.70 (passed on at least v4.0 for FFXV) sitting next to me. Props! :)
 

Lord Pyro ARSON

Senior Member
Contributor
I wonder how long it will take? Wait does this mean the ps4 pro will run every game in steamOS it is a powerful console after all.. still waiting for cfw on the base model though
 

BiRDBOY

Member
Contributor
So this means I can play for example MW3 on steam from my ps4? or GTA 5. But would this so only support Linux games? and is it worth to jailbreak a ps4 pro, after all I just bought it after my 2 other ps4s, so I don't really want to risk my ps4, but I would definitely want Steam on my PS4 :)
 

yota1979

Senior Member
Contributor
I think it's great and it's wonderful if also we can try to do this on own ps4 / ps4 pro. I'd like to try to install linux on my ps4 , but if we don't have the webkit exploitand the kernel exploit .... the fun is only for a few people!
 

Stanimir

Senior Member
Contributor
For those asking if the PS4 Pro will be stronger linux than the normal PS4. NO. Sorry lol, but yeah it won't make a grave difference. Even on a normal PS4 once we get full driver access MW3 and GTA V (Low settings for GTA V) would probably play anyways. Hey, but booking dolphin on PS4? Lol sounds like a plan.
 
Recent Articles
PS4 System Software / Firmware 7.01 is Now Live, Don't Update!
It figures Sony wouldn't let the holidays roll by without giving the PlayStation 4 scene a present worthy of regifting, and today following their previous PS4 OFW update comes PS4 System Software...
Resident Evil 3 Returns to PlayStation 4 on April 3rd, 2020
In the footsteps of Resident Evil 2 on PS4 comes Capcom's return to Raccoon City in Resident Evil 3 arriving on PlayStation 4 next April 3rd, 2020! šŸ¦ Here are some RE3 PS4 screenshots alongside...
Sony PlayStation State of Play Live Stream for December 10th, 2019
Today as scheduled Sony held their last PlayStation State of Play December 2019 conference for the year, with a recap of the live stream and video game highlights below for those who missed it...
Redbox Video Game Rentals to End This Year, Game Sales by Early 2020
As GameStop reported massive financial losses and announced the closing of more stores this year, it appears Redbox is getting out of the video game rental business by the end of 2019... they'll...
Top